GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix Path Traversal in multissltests.py · Issue #138158 · python/cpython

Fix Path Traversal in multissltests.py #138158

New issue
Copy link
New issue
Copy link
Closed
Closed
Fix Path Traversal in multissltests.py#138158
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

Description

@ParzivalHack
ParzivalHack
opened on Aug 26, 2025
Issue body actions

Tools/ssl/multissltests.py suffers from a possible Path Traversal attack. The vulnerability allows for a crafted tarball to write an arbitrary file to a location outside of the intended build directory due to a lack of sanitization in the _unpack_src() method's handling of tarball member names.

A comprehensive, self-contained PoC script was used to demonstrate the issue (and shared with the Python Security Response Team, henceforth PSRT), confirming the Path Traversal. The fix implemented in this PR ensures that each tarball member is manually extracted with a path check, preventing any file from escaping the designated directory. This approach provides a clear and robust solution to the issue.

As this is a test script, and not a production component, the PSRT has advised me to submitt it as a public enhancement. This fix ensures the integrity and robustness of the tool, by preventing an unprivileged file write that could lead to unexpected behavior.

I am submitting this enhancement to improve the overall quality of the CPython test suite. If necessary, I'm available to provide any additional information required for review.

PoC: https://github.com/ParzivalHack/PT-PoC.

Linked PRs

  • gh-138158: Use the "data" tarfile extraction filter in Tools/ssl/multissltests.py #138147
  • [3.14] gh-138158: Use the "data" tarfile extraction filter in Tools/ssl/multissltests.py (GH-138147) #138262
  • [3.13] gh-138158: Use the "data" tarfile extraction filter in Tools/ssl/multissltests.py (GH-138147) #138263

Activity

  1. ZeroIntensity
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    type-securityA security issueA security issue
    on Aug 26, 2025
  2. picnixz commented on Aug 30, 2025

    @picnixz
    picnixz
    on Aug 30, 2025
    Member
    More actions

    I'm forwarding my rationale for accepting this issue:

    I thought about this a lot, because I originally didn't want un-necessary churn, even if it's helpful. However, it's actually possible for the user to skip the download part and directly specify a directory where the lib sources are. So, assuming that this directory is untrusted, it's entirely possible to have a bad archive out there. The attack surface is really small as this requires executing the script in a non-standard way, but I think it's a legitimate improvement.

    Now, in Python 3.14 and later, the data filter is the default, but if PYTHON_FOR_REGEN is Python 3.13 or below, then it won't be the default. I'm not sure whether we should backport this up to 3.9 because there might be users (downstream distros?) relying on this script but that don't download remote sources in an offline environment (and the sources are shipped in the installation disk for instance, I don't know). Anyway, for now, I'm only planning to backport this up to 3.13.

  3. picnixz
    added a commit that references this issue on Aug 30, 2025

    gh-138158: Use the `"data"` tarfile extraction filter in `Tools/ssl/m…

    31d3836
  4. miss-islington
    added 2 commits that reference this issue on Aug 30, 2025

    pythongh-138158: Use the `"data"` tarfile extraction filter in `Tools…

    543557c

    pythongh-138158: Use the `"data"` tarfile extraction filter in `Tools…

    68c170e
  5. picnixz commented on Aug 30, 2025

    @picnixz
    picnixz
    on Aug 30, 2025
    Member
    More actions

    We could theoretically backport this up to 3.9 but I don't think I'm going to do it. The vulnerabililty is too theoretical to be considered as a true security issue IMO, but maybe the PSRT has something else to say here.

    @sethmlarson AFAICT, it's possible to make something bad here, but it's a test-only script so, unless downstream distributions are worried about this, I don't think it's necessary to commit more stuff to security-only branches for this one, but if you want to do it, feel free to add the backport labels on the PR.

  6. picnixz
    added a commit that references this issue on Aug 30, 2025

    [3.13] gh-138158: Use the `"data"` tarfile extraction filter in `Tool…

    8dd0276
  7. picnixz
    added
    type-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)
    and removed
    type-securityA security issueA security issue
    on Aug 30, 2025
  8. sethmlarson commented on Aug 30, 2025

    @sethmlarson
    sethmlarson
    on Aug 30, 2025
    Contributor
    More actions

    Yeah this isn't a security issue (and we discussed that in PSRT). Doesn't need to be backported, either, as it doesn't make tests any more reliable/passing. Just a nice to have into the future!

  9. picnixz commented on Aug 30, 2025

    @picnixz
    picnixz
    on Aug 30, 2025
    Member
    More actions

    Oh I already backported it to 3.13. Should I revert it? (3.14 backport is not yet merged). Should we still merge the 3.14 backport? (by backports in my previous comment, I meant the 3.9 to 3.12 ones)

  10. zware commented on Aug 30, 2025

    @zware
    zware
    on Aug 30, 2025
    Member
    More actions

    I don't think it's worth reverting or backporting further, but the 3.14 PR should be merged eventually just to avoid being the odd one out between 3.13 and 3.15.

    Reacted by Bénédikt Tran
  11. hugovk
    added a commit that references this issue on Aug 31, 2025

    [3.14] gh-138158: Use the `"data"` tarfile extraction filter in `Tool…

    b79bece
  12. hugovk commented on Aug 31, 2025

    @hugovk
    hugovk
    on Aug 31, 2025
    Member
    More actions

    Thanks, 3.14 merged!

    Reacted by Bénédikt Tran
  13. hugovk
    closed this as completedon Aug 31, 2025
  14. kumaraditya303
    added a commit that references this issue on Sep 9, 2025

    [3.14] pythongh-138158: Use the `"data"` tarfile extraction filter in…

    b8e9bc5
  15. lkollar
    added a commit that references this issue on Sep 9, 2025

    pythongh-138158: Use the `"data"` tarfile extraction filter in `Tools…

    d93c021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirTests in the Lib/test dirtype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.