Title: tarfile: Windows same-drive drive-relative symlink not caught by data filter · Issue #161323 · python/cpython · GitHub
Open Graph Title: tarfile: Windows same-drive drive-relative symlink not caught by data filter · Issue #161323 · python/cpython
X Title: tarfile: Windows same-drive drive-relative symlink not caught by data filter · Issue #161323 · python/cpython
Description: Bug report On Windows, a member name or link target with a drive but no root, such as C:foo, is not absolute, so the 'tar' and 'data' extraction filters let it through. Their containment check joins it onto the resolved destination, whic...
Open Graph Description: Bug report On Windows, a member name or link target with a drive but no root, such as C:foo, is not absolute, so the 'tar' and 'data' extraction filters let it through. Their containment check join...
X Description: Bug report On Windows, a member name or link target with a drive but no root, such as C:foo, is not absolute, so the 'tar' and 'data' extraction filters let it through. Their contai...
Opengraph URL: https://github.com/python/cpython/issues/161323
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"tarfile: Windows same-drive drive-relative symlink not caught by data filter","articleBody":"### Bug report\n\nOn Windows, a member name or link target with a drive but no root, such as `C:foo`, is not absolute, so the `'tar'` and `'data'` extraction filters let it through. Their containment check joins it onto the resolved destination, which has the same drive, so it looks contained. Extraction then joins the name onto the destination as given: with `extractall(\"out\")`, `os.path.join(\"out\", \"C:foo\")` is `\"C:foo\"`, a file in the current directory of drive C:. A symlink to `C:foo` passes the `'data'` filter the same way and is resolved against that directory too. `x/../C:foo` and `./C:foo` become `C:foo` through the filter's own normalization.\n\nThis runs the filters with Windows path handling on any OS:\n\n```python\nimport ntpath, os, tarfile\nos.path = ntpath\nos.getcwd = lambda: r'C:\\work'\nfor name in 'C:evil.txt', 'x/../C:evil.txt':\n member = tarfile.data_filter(tarfile.TarInfo(name), 'out')\n print(repr(name), '->', ntpath.abspath(ntpath.join('out', member.name)))\nlink = tarfile.TarInfo('link')\nlink.type = tarfile.SYMTYPE\nlink.linkname = './C:evil.txt'\nprint('symlink ->', repr(tarfile.data_filter(link, 'out').linkname))\n```\n\n```\n'C:evil.txt' -> C:\\work\\evil.txt\n'x/../C:evil.txt' -> C:\\work\\evil.txt\nsymlink -> 'C:evil.txt'\n```\n\nThe filters should refuse these with `AbsolutePathError` and `AbsoluteLinkError`. gh-154987 is the different-drive case, where the containment check raises `ValueError` instead.\n\n---\n\nReported as a security issue via GHSA by Girish Konda. Assigned CVE-2026-107784.\n_also later found by anthropic/oss-scanner as ANT-2026-RSL1F4AT_\n\nPR ready, reviewed, and approved via GHSA, i'll push that after opening this.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-161334\n* gh-161355\n* gh-161356\n* gh-161357\n* gh-161358\n* gh-161359\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/gpshead","@type":"Person","name":"gpshead"},"datePublished":"2026-11-04T16:27:33Z","url":"https://github.com/python/cpython/issues/161323"}
| 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:cc479dec-15b3-0bf4-01b7-02ef738aa360 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 911C:2DBB21:364C79D:486C120:6B020E15 |
| html-safe-nonce | 850cdc06fc72661ad3c26d356baaffc202e1777991c305ee1d9807b80878edfa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MTFDOjJEQkIyMTozNjRDNzlEOjQ4NkMxMjA6NkIwMjBFMTUiLCJ2aXNpdG9yX2lkIjoiOTIxMDgxOTc0MzMyNDQ0MjEzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8c42ea70f1072b965e3c539433d2a7e64295fecdd54cc8f63270bb2d2a6ace86 |
| hovercard-subject-tag | issue:6206882216 |
| 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/161323/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ed8f0fd6dd33b161936e1b4d4895b06221cb41ff73191e72b52dcee3c4cb9751/python/cpython/issues/161323 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ed8f0fd6dd33b161936e1b4d4895b06221cb41ff73191e72b52dcee3c4cb9751/python/cpython/issues/161323 |
| og:image:alt | Bug report On Windows, a member name or link target with a drive but no root, such as C:foo, is not absolute, so the 'tar' and 'data' extraction filters let it through. Their containment check join... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gpshead |
| 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