Title: gh-156026: Document that the 'tar' filter does not bound link targets by drengir1 · Pull Request #158038 · python/cpython · GitHub
Open Graph Title: gh-156026: Document that the 'tar' filter does not bound link targets by drengir1 · Pull Request #158038 · python/cpython
X Title: gh-156026: Document that the 'tar' filter does not bound link targets by drengir1 · Pull Request #158038 · python/cpython
Description: Documentation only. No behaviour change. tar_filter does not check TarInfo.linkname, so a symbolic link member whose target is absolute, or relative and climbing outside the destination, is extracted as given. Only data_filter refuses those. That is consistent with PEP 706 and I am not proposing to change it — but the docs never say it, and the containment bullet of tar_filter reads as though they do: Refuse to extract files whose absolute path (after following symlinks) would end up outside the destination. "(after following symlinks)" describes realpath() on the member's own destination path, not the link target the member creates. Today the non-guarantee is derivable only by noticing that data_filter says "In addition to what tar_filter does" and that link-target containment appears only in that second list. The recently added normalization bullet sharpens this rather than covering it: it now warns that removing internal .. components "may change the meaning of the name if it traverses symbolic links", so the section does discuss symlinks — but only as they affect a member's own name. linkname is still never mentioned. This adds two things: One clause in the 'tar' entry of the filter list, since that list is where the choice between 'tar' and 'data' is actually made. A .. warning:: on tar_filter stating the non-guarantee positively and pointing at data_filter. It is placed before the existing .. versionchanged:: note so version history stays last. Motivation and the measured behaviour (with controls, and with the scope limited to symbolic links, which is what I verified) are in #156026. Briefly: five independent projects picked 'tar' in code whose stated purpose is safe extraction — unstructured-ingest, container-inspector, portage, poetry, and Samba's safe_tarfile.py, whose comment "which prevents escape" is close to a verbatim restatement of the bullet above. No Misc/NEWS.d entry — docs-only change, so this should carry skip news. Happy to reword any of it; I care that the fact is stated somewhere in the tar_filter section, not about the phrasing. Issue: gh-156026
Open Graph Description: Documentation only. No behaviour change. tar_filter does not check TarInfo.linkname, so a symbolic link member whose target is absolute, or relative and climbing outside the destination, is extract...
X Description: Documentation only. No behaviour change. tar_filter does not check TarInfo.linkname, so a symbolic link member whose target is absolute, or relative and climbing outside the destination, is extract...
Opengraph URL: https://github.com/python/cpython/pull/158038
X: @github
Domain: github.com
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:fdbe7c37-a30c-b78c-fe9a-ab4ae4c80d2d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B698:24645:256C305:31104DE:6B025886 |
| html-safe-nonce | a8470a5c6dbbae3ed511eb3e5959356c5a97755157c5cd927ffdef93e6818dcb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjk4OjI0NjQ1OjI1NkMzMDU6MzExMDRERTo2QjAyNTg4NiIsInZpc2l0b3JfaWQiOiI4Mjg5MjAwNzg2MTYwOTAwMjMwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9ecd358551bb99441ba7639b6f1c6c4158ee4e730f4852ee66411fb6d3c33d8a |
| hovercard-subject-tag | pull_request:4619174665 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/158038/files |
| twitter:image | https://avatars.githubusercontent.com/u/198132210?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/198132210?s=400&v=4 |
| og:image:alt | Documentation only. No behaviour change. tar_filter does not check TarInfo.linkname, so a symbolic link member whose target is absolute, or relative and climbing outside the destination, is extract... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 | true |
| 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 |
Links:
Viewport: width=device-width