René's URL Explorer Experiment


Title: Doc/library/tarfile.rst: document that the 'tar' extraction filter does not bound link targets · Issue #156026 · python/cpython · GitHub

Open Graph Title: Doc/library/tarfile.rst: document that the 'tar' extraction filter does not bound link targets · Issue #156026 · python/cpython

X Title: Doc/library/tarfile.rst: document that the 'tar' extraction filter does not bound link targets · Issue #156026 · python/cpython

Description: Documentation Documentation Doc/library/tarfile.rst, the "Extraction filters" section — specifically tar_filter and the 'tar' entry in the filter list. Summary The 'tar' extraction filter does not check TarInfo.linkname. A symbolic link ...

Open Graph Description: Documentation Documentation Doc/library/tarfile.rst, the "Extraction filters" section — specifically tar_filter and the 'tar' entry in the filter list. Summary The 'tar' extraction filter does not ...

X Description: Documentation Documentation Doc/library/tarfile.rst, the "Extraction filters" section — specifically tar_filter and the 'tar' entry in the filter list. Summary The 'tar' e...

Opengraph URL: https://github.com/python/cpython/issues/156026

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Doc/library/tarfile.rst: document that the 'tar' extraction filter does not bound link targets","articleBody":"### Documentation\n\n# Documentation\n\n`Doc/library/tarfile.rst`, the \"Extraction filters\" section — specifically `tar_filter` and the `'tar'` entry in the filter list.\n\n## Summary\n\nThe `'tar'` extraction filter does not check `TarInfo.linkname`. A symbolic link member whose target is an absolute path, or a relative path that climbs outside the destination, is extracted as given. Only `'data'` refuses such members.\n\nThis is deliberate and consistent with PEP 706 — **I am not proposing a behaviour change.** The problem is that the documentation never states it, and one sentence in the `tar_filter` description reads as though it does the opposite.\n\n## Where the docs mislead\n\n`tar_filter`'s third bullet currently reads:\n\n> Refuse to extract files whose absolute path (after following symlinks) would end up outside the destination. This raises `OutsideDestinationError`.\n\nThe parenthetical \"(after following symlinks)\" describes `os.path.realpath()` applied to the member's **own destination path** — i.e. symlinks that already exist in the destination tree. It reads naturally as \"symlink-related escapes are handled here\".\n\nThat link *targets* are unchecked is currently derivable only by *absence*: the reader has to notice that `data_filter` is introduced with \"In addition to what `tar_filter` does\", and that link-target containment appears only in that second list. The non-guarantee is never stated positively, so nobody reading the `tar_filter` section can learn it from that section.\n\n## Why it matters in practice\n\nI found this because five independent projects selected the `'tar'` filter (or `tarfile.tar_filter` directly) in code whose stated purpose is safe extraction, leaving link targets unbounded as a result: `unstructured-ingest`, `container-inspector`, `portage`, `poetry`, and Samba's `python/samba/safe_tarfile.py`. Each has been reported to its maintainers separately; I am raising this here because five independent readings landing the same way looks like a docs problem rather than five coincidences.\n\nSamba's case shows the mechanism most clearly, because the comment quotes the docs almost verbatim:\n\n```python\n# The 'data' filter preserves no permissions so we select the\n# intermediate 'tar' filter here which prevents escape but\n# preserves permissions.\nextraction_filter = staticmethod(tarfile.tar_filter)\n```\n\n\"which prevents escape\" is a restatement of the bullet above. That same class's pre-3.12 fallback implements `_is_unsafe_symlink()` and `_is_unsafe_link()` by hand — so the module became *less* strict when it moved to the stdlib filter, which is presumably the opposite of what was intended.\n\n## Measurement\n\nPython 3.10.12 on Linux. The harness diffs the destination tree against a pre-extraction snapshot, so a member that was never created cannot be miscounted as written, and it runs with `errorlevel=2` so nothing is silently skipped.\n\n```\nCONTROLS -- if these do not pass, nothing below means anything\n  CONTROL-BENIGN plain file     filter=tar   -> extracted                          [ok]\n  CONTROL-BENIGN plain file     filter=data  -> extracted                          [ok]\n  CONTROL-DOTDOT member path    filter=tar   -> REFUSED (OutsideDestinationError)  [ok]\n  CONTROL-DOTDOT member path    filter=data  -> REFUSED (OutsideDestinationError)  [ok]\n\nPAYLOADS -- symlink TARGETS\n  sym -> /etc                   filter=tar   -> LINK CREATED, POINTS OUTSIDE\n  sym -> /etc                   filter=data  -> REFUSED (AbsoluteLinkError)\n  sym -> /etc/passwd            filter=tar   -> LINK CREATED, POINTS OUTSIDE\n  sym -> /etc/passwd            filter=data  -> REFUSED (AbsoluteLinkError)\n  sym -> ../../OUTSIDE          filter=tar   -> LINK CREATED, POINTS OUTSIDE\n  sym -> ../../OUTSIDE          filter=data  -> REFUSED (LinkOutsideDestinationError)\n```\n\nThe `CONTROL-DOTDOT` row is the one that makes the rest meaningful: `tar_filter` genuinely does close the original CVE-2007-4559 path-traversal case, so \"refused\" is observable in this harness and the symlink rows are a real difference rather than a broken probe.\n\nReading through the resulting link works:\n\n```\nread through .../sandbox/lvl1/lvl2/dest/secrets\n  -> /etc/passwd line 1: 'root:x:0:0:root:/root:/bin/bash'\n```\n\nStated precisely so the proposed wording is not overclaimed: writing *through* such a link with a later member in the same archive is refused (`OutsideDestinationError`), because each member path is re-resolved at extraction time. Under `'tar'` this is link placement and file read, not arbitrary write. Hard links to absolute outside paths failed here for an unrelated reason (`ExtractError` during link-target resolution), so I make no claim about them — the wording below covers symbolic links, which is what I measured.\n\n## Proposed change\n\nTwo edits, no behaviour change:\n\n1. In the filter list, the `'tar'` entry gains one clause, since that list is where the choice between `'tar'` and `'data'` is actually made:\n\n```rst\n* the string ``'tar'``: Honor most *tar*-specific features (i.e. features of\n  UNIX-like filesystems), but block features that are very likely to be\n  surprising or malicious. This does not include limiting the targets of\n  symbolic links. See :func:`tar_filter` for details.\n```\n\n2. `tar_filter` gains a warning stating the non-guarantee positively:\n\n```rst\n  .. warning::\n\n     This filter does not limit where a link member *points*.\n     :attr:`TarInfo.linkname` is not checked, so a symbolic link whose target\n     is an absolute path, or a relative path that climbs outside the\n     destination, is extracted as given.\n     The rule above constrains where each member is *written*; it does not\n     constrain where a link resolves to.\n\n     Only :func:`data_filter` refuses such members, raising\n     :class:`~tarfile.AbsoluteLinkError` or\n     :class:`~tarfile.LinkOutsideDestinationError`.\n```\n\nI have this as a patch and am happy to open the PR. I care that the fact appears somewhere in the `tar_filter` section — the phrasing is entirely yours to change.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156056\n* gh-158038\n* gh-159019\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/drengir1","@type":"Person","name":"drengir1"},"datePublished":"2026-08-18T18:53:17Z","url":"https://github.com/python/cpython/issues/156026"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:3be669c8-3f47-73c3-e609-6243a5a1965f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD13C:3CBB3E:3BD72C2:4C39722:6B025006
html-safe-nonceba5aae11424cc9b80f6556aceb01d2fd54427769cdce08fac3c5b758ee5c2b7b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTNDOjNDQkIzRTozQkQ3MkMyOjRDMzk3MjI6NkIwMjUwMDYiLCJ2aXNpdG9yX2lkIjoiODQ3MTI3NjA3NjMxNDgwODMyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac1b854bbd6d1e68ddcbf0e8e2f2f259e173f1cb20e7c6dfe99c363c77cb91d52d
hovercard-subject-tagissue:5185208728
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/156026/issue_layout
twitter:imagehttps://opengraph.githubassets.com/10cc336c712925a3d4679457ece2084ff8d765f993794caca4fd8f710ab33dea/python/cpython/issues/156026
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/10cc336c712925a3d4679457ece2084ff8d765f993794caca4fd8f710ab33dea/python/cpython/issues/156026
og:image:altDocumentation Documentation Doc/library/tarfile.rst, the "Extraction filters" section — specifically tar_filter and the 'tar' entry in the filter list. Summary The 'tar' extraction filter does not ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedrengir1
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/156026#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F156026
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F156026
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/156026
Reloadhttps://github.com/python/cpython/issues/156026
Reloadhttps://github.com/python/cpython/issues/156026
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/156026
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/156026
Doc/library/tarfile.rst: document that the 'tar' extraction filter does not bound link targetshttps://github.com/python/cpython/issues/156026#top
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
https://github.com/drengir1
drengir1https://github.com/drengir1
on Aug 18, 2026https://github.com/python/cpython/issues/156026#issue-5185208728
CVE-2007-4559https://github.com/advisories/GHSA-gw9q-c7gh-j9vm
gh-156026: document tar filter link targets #156056https://github.com/python/cpython/pull/156056
gh-156026: Document that the 'tar' filter does not bound link targets #158038https://github.com/python/cpython/pull/158038
gh-156026: Add warning about link targets to tarfile.tar_filter #159019https://github.com/python/cpython/pull/159019
drengir1https://github.com/drengir1
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
on Aug 18, 2026https://github.com/python/cpython/issues/156026#event-29639090167
github-project-automationhttps://github.com/apps/github-project-automation
docs issueshttps://github.com/orgs/python/projects/52
on Aug 18, 2026https://github.com/python/cpython/issues/156026#event-29639104733
github-project-automationhttps://github.com/apps/github-project-automation
docs issueshttps://github.com/orgs/python/projects/52
on Aug 18, 2026https://github.com/python/cpython/issues/156026
drengir1https://github.com/drengir1
on Sep 23, 2026https://github.com/python/cpython/issues/156026#event-31712899282
pythongh-156026: Document that the 'tar' filter does not bound link t…https://github.com/drengir1/cpython/commit/8bfc40580056f5a467e953f933a23b26268e6ceb
pythongh-156026https://github.com/python/cpython/issues/156026
8bfc405https://github.com/drengir1/cpython/commit/8bfc40580056f5a467e953f933a23b26268e6ceb
StanFromIrelandhttps://github.com/StanFromIreland
tar_filter behavior with links outside the destination is not clearly documented #158970https://github.com/python/cpython/issues/158970
on Oct 7, 2026https://github.com/python/cpython/issues/156026#event-32726146825
https://github.com/encukou
encukouhttps://github.com/encukou
on Oct 8, 2026https://github.com/python/cpython/issues/156026#issuecomment-6059460980
ethanfurmanhttps://github.com/ethanfurman
on Oct 12, 2026https://github.com/python/cpython/issues/156026#event-33072763774
gh-156026: document tar filter link targets (GH-156056)https://github.com/python/cpython/commit/e29cce5ea81f94de936521cada96f2ffd5d42df1
gh-156026https://github.com/python/cpython/issues/156026
GH-156056https://github.com/python/cpython/pull/156056
e29cce5https://github.com/python/cpython/commit/e29cce5ea81f94de936521cada96f2ffd5d42df1
gh-156026: Add warning about link targets to tarfile.tar_filter (GH-1…https://github.com/python/cpython/commit/a6b4aa687cd9f8f95e3b940e6314ac8f2a85fbbb
gh-156026https://github.com/python/cpython/issues/156026
GH-1…https://github.com/python/cpython/pull/159019
a6b4aa6https://github.com/python/cpython/commit/a6b4aa687cd9f8f95e3b940e6314ac8f2a85fbbb
ethanfurmanhttps://github.com/ethanfurman
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 14, 2026https://github.com/python/cpython/issues/156026#event-33277335432
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/156026
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/156026
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
docs issueshttps://github.com/orgs/python/projects/52
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.