Title: tar_filter behavior with links outside the destination is not clearly documented · Issue #158970 · python/cpython · GitHub
Open Graph Title: tar_filter behavior with links outside the destination is not clearly documented · Issue #158970 · python/cpython
X Title: tar_filter behavior with links outside the destination is not clearly documented · Issue #158970 · python/cpython
Description: Bug report The tar extraction filter allows archive members to create hard links or symbolic links that point outside the extraction directory. I understand from the security response that this is intentional, mainly to allow things such...
Open Graph Description: Bug report The tar extraction filter allows archive members to create hard links or symbolic links that point outside the extraction directory. I understand from the security response that this is ...
X Description: Bug report The tar extraction filter allows archive members to create hard links or symbolic links that point outside the extraction directory. I understand from the security response that this is ...
Opengraph URL: https://github.com/python/cpython/issues/158970
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"tar_filter behavior with links outside the destination is not clearly documented","articleBody":"### Bug report\n\nThe `tar` extraction filter allows archive members to create hard links or symbolic links that point outside the extraction directory.\n\nI understand from the security response that this is intentional, mainly to allow things such as `/dev/null` and other system paths. However, I think the current documentation does not make the security implications of this behavior clear enough.\n\nThe documentation for `tar_filter` currently describes it as refusing to extract files whose absolute path, after following symlinks, would end up outside the destination. This can be easy to interpret as meaning that links themselves are restricted to the extraction directory.\n\nFor example, an archive can contain a hard link with an absolute target such as:\n\n```text\n/home/user/example\n```\n\nWhen extracted with:\n\n```python\ntar.extractall(destination, filter=\"tar\")\n```\n\nthe hard link can point to the existing file outside `destination`.\n\nThis is different from the behavior of the `data` filter, which rejects links that point outside the destination.\n\nI think the `tar_filter` documentation should explicitly state that:\n\n* Links are allowed to point outside the extraction directory.\n* This includes both absolute and relative link targets where applicable.\n* Extracting an untrusted archive with `filter=\"tar\"` may therefore create links to files outside the extraction directory.\n* Applications that need to safely extract untrusted archives should use the `data` filter instead.\n\nSomething along those lines would make the distinction between `tar` and `data` much harder to misunderstand.\n\n### Why this matters\n\nAn application developer may reasonably assume that using `filter=\"tar\"` provides a strong boundary around the extraction directory, especially because the documentation discusses preventing files from ending up outside the destination.\n\nExplicitly documenting that external links are intentionally permitted would make the behavior much clearer and help prevent applications from using the wrong filter for untrusted archives.\n\nI can provide a minimal reproducer showing the behavior if useful.\n\n### CPython versions tested on:\n\n3.12, 3.13, 3.14, CPython main branch\n\n### Operating systems tested on:\n\nLinux","author":{"url":"https://github.com/gpt4omni","@type":"Person","name":"gpt4omni"},"datePublished":"2026-10-07T14:44:39Z","url":"https://github.com/python/cpython/issues/158970"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:df082662-7115-9a5e-c88d-df0c6b7e260f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B4B0:2C4BED:4A78A8A:5E4F219:6B0253E1 |
| html-safe-nonce | 55ad482d41e641373a4694a56991eeb5b25eb0549e74361cb671e4d8bc187291 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNEIwOjJDNEJFRDo0QTc4QThBOjVFNEYyMTk6NkIwMjUzRTEiLCJ2aXNpdG9yX2lkIjoiODYyNTA2MDE1NDg5Njk2MjUyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ab454d13e58598fbd956c0f8fc56da0d3493a48b935dbcde4064f28380dc09ec |
| hovercard-subject-tag | issue:5746939065 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/158970/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fa7ead14c165660574968ae38faa4688d7623177c1d2fbe065468bf360a71c1b/python/cpython/issues/158970 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fa7ead14c165660574968ae38faa4688d7623177c1d2fbe065468bf360a71c1b/python/cpython/issues/158970 |
| og:image:alt | Bug report The tar extraction filter allows archive members to create hard links or symbolic links that point outside the extraction directory. I understand from the security response that this is ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gpt4omni |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width