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 — gh-138158: Use the `"data"` tarfile extraction filter in `Tools/ssl/multissltests.py` by ParzivalHack · Pull Request #138147 · python/cpython

Conversation

@ParzivalHack

@ParzivalHack ParzivalHack commented Aug 25, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This pull request addresses a path traversal vulnerability in the Tools/ssl/multissltests.py script. 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 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 Python Security Response Team (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.

  • Issue: Fix Path Traversal in multissltests.py #138158

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ParzivalHack
Fix Path Traversal in multissltests.py
52110d7
Fix of a Path Traversal vulnerability in a test script in multissltests.py
@ParzivalHack
ParzivalHack requested review from gpshead and picnixz as code owners August 25, 2025 18:16
@python-cla-bot

python-cla-bot Bot commented Aug 25, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label Aug 25, 2025
@bedevere-app

This comment was marked as resolved.

Sign in to view
@StanFromIreland StanFromIreland added skip news tests Tests in the Lib/test dir topic-SSL labels Aug 25, 2025
AA-Turner
AA-Turner previously requested changes Aug 26, 2025
View reviewed changes

@AA-Turner AA-Turner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you have several unrelated whitespace changes; please revert.

A

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting review labels Aug 26, 2025
@bedevere-app

bedevere-app Bot commented Aug 26, 2025

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StanFromIreland

StanFromIreland commented Aug 26, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

FYI These are the whitespace changes that should be reverted:

image
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ParzivalHack
Update multissltests.py
7276b4f
Reverted the unrelated whitespace changes
@ParzivalHack

ParzivalHack commented Aug 26, 2025

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels Aug 26, 2025
@bedevere-app

bedevere-app Bot commented Aug 26, 2025

Copy link
Copy Markdown

Thanks for making the requested changes!

@AA-Turner: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested a review from AA-Turner August 26, 2025 07:58
StanFromIreland
StanFromIreland reviewed Aug 26, 2025
View reviewed changes
Comment thread Tools/ssl/multissltests.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz reviewed Aug 26, 2025
View reviewed changes

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR overcomplicates a script that is already complex. The URLs are safe as they are hardcoded. I don't think we need to worry about this kind of attack, unless upstream is affected (namely official openssl, libressl or aws-lc repositories).

Has this PR been generated by AI?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AA-Turner reacted with confused emoji
All reactions
  • 😕 1 reaction
picnixz
picnixz previously requested changes Aug 26, 2025
View reviewed changes

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever we choose to do, an issue should be opened first. However, I don't think such change is needed, but to be on the perfectly safe side, we could just specify the filter in extractall.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

StanFromIreland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Tools/ssl/multissltests.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Tools/ssl/multissltests.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Tools/ssl/multissltests.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting change review label Aug 26, 2025
@bedevere-app

bedevere-app Bot commented Aug 26, 2025

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting changes label Aug 26, 2025
@picnixz picnixz added the DO-NOT-MERGE label Aug 26, 2025
ParzivalHack and others added 2 commits August 26, 2025 11:40
@ParzivalHack @StanFromIreland
Update Tools/ssl/multissltests.py
d264c0d
Remove additional whitespace

Co-authored-by: Stan Ulbrych <[email protected]>
@ParzivalHack
Refactor _unpack_src to use tarfile data filter
cb20c2f
This commit refactors the _unpack_src function to use the filter='data' argument in tarfile.extractall(). This change addresses the path traversal vulnerability more robustly, as suggested during code review. It also improves code clarity and removes the need for manual path validation checks.
@picnixz picnixz removed the DO-NOT-MERGE label Aug 26, 2025
AA-Turner
AA-Turner reviewed Aug 26, 2025
View reviewed changes

@AA-Turner AA-Turner left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the data filter seems harmless. I agree with Ben (& the PSRT) though that there is no practical 'vulnerability' here, so this is largely a change for theoretical purposes. As such, I'm +0; will leave to someone else to decide to merge.

A

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AA-Turner
AA-Turner dismissed their stale review August 26, 2025 12:43

+0

@bedevere-app bedevere-app Bot added awaiting review and removed awaiting change review labels Aug 26, 2025
@ParzivalHack
ParzivalHack requested a review from picnixz August 28, 2025 21:23
@picnixz

picnixz commented Aug 30, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

I need to test it locally though, (or @ParzivalHack, could you check that this effectively prevents the PT attack and share your PoC please?).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ParzivalHack

ParzivalHack commented Aug 30, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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.

I need to test it locally though, (or @ParzivalHack, could you check that this effectively prevents the PT attack and share your PoC please?).

Hey @picnixz,
Thanks for your feedback and for looking into this (again). I've re-tested the fix locally and can confirm that using the filter='data' argument fully prevents the path traversal attack.

I've put together a small (but detailed) repo with the PoC script, including a README.md that shows a side-by-side comparison of the vulnerable and patched outcomes.

You can check it out here: https://github.com/ParzivalHack/PT-PoC

Lmk if there's anything else I can do👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Aug 30, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Thank you for the PoC. Actually, I just looked at the docs for tarfile, but apparently, the data filter is the default filter for Python 3.14 and later. Which version are you using for Python? with Python 3.14+, extractall() shouldn't need to specify its extraction filter.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ParzivalHack

ParzivalHack commented Aug 30, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Thank you for the PoC. Actually, I just looked at the docs for tarfile, but apparently, the data filter is the default filter for Python 3.14 and later. Which version are you using for Python? with Python 3.14+, extractall() shouldn't need to specify its extraction filter.

No worries. And i was running everything with Python 3.13.3👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Aug 30, 2025

Copy link
Copy Markdown
Member

So that's the reason why it's vulnerable. However, as I mentioned on the issue, if someone is using Python 3.13 and below for PYTHON_FOR_REGEN, then they could suffer from this so I'm ok with this change.

ParzivalHack reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz approved these changes Aug 30, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Aug 30, 2025
@picnixz picnixz added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels Aug 30, 2025
@ParzivalHack

ParzivalHack commented Aug 30, 2025

Copy link
Copy Markdown
Contributor Author

So that's the reason why it's vulnerable. However, as I mentioned on the issue, if someone is using Python 3.13 and below for PYTHON_FOR_REGEN, then they could suffer from this so I'm ok with this change.

Hey @picnixz,
Thanks for your review and feedback. Appreciate your help in getting this resolved.

Thanks again for the opportunity to contribute :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz picnixz changed the title gh-138158: Use the 'data' tarfile filter for multissltests gh-138158: Use the "data" tarfile extraction filter in Tools/ssl/multissltests.py Aug 30, 2025
@picnixz
picnixz merged commit 31d3836 into python:main Aug 30, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 30, 2025
@miss-islington-app

miss-islington-app Bot commented Aug 30, 2025

Copy link
Copy Markdown

Thanks @ParzivalHack for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

ParzivalHack reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 30, 2025
@ParzivalHack @miss-islington
pythongh-138158: Use the "data" tarfile extraction filter in `Tools…
543557c
…/ssl/multissltests.py` (pythonGH-138147)

The `Tools/ssl/multissltests.py` script may extract a possibly untrusted tarball.
Since the script does not necessarily use Python 3.14 or later (where the `"data"`
filter became the default `tarfile` extraction filter), the user may theoretically
suffer from a path traversal attack.

Although the script should not be used in production and usually relies on downloading
trusted sources, the `"data"` extraction filter is now explicitly used wherever relevant.
(cherry picked from commit 31d3836)

Co-authored-by: Tommaso Bona <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 30, 2025
@ParzivalHack @miss-islington
pythongh-138158: Use the "data" tarfile extraction filter in `Tools…
68c170e
…/ssl/multissltests.py` (pythonGH-138147)

The `Tools/ssl/multissltests.py` script may extract a possibly untrusted tarball.
Since the script does not necessarily use Python 3.14 or later (where the `"data"`
filter became the default `tarfile` extraction filter), the user may theoretically
suffer from a path traversal attack.

Although the script should not be used in production and usually relies on downloading
trusted sources, the `"data"` extraction filter is now explicitly used wherever relevant.
(cherry picked from commit 31d3836)

Co-authored-by: Tommaso Bona <[email protected]>
@bedevere-app

bedevere-app Bot commented Aug 30, 2025

Copy link
Copy Markdown

GH-138262 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 30, 2025
@bedevere-app

bedevere-app Bot commented Aug 30, 2025

Copy link
Copy Markdown

GH-138263 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Aug 30, 2025
picnixz pushed a commit that referenced this pull request Aug 30, 2025
@miss-islington @ParzivalHack
[3.13] gh-138158: Use the "data" tarfile extraction filter in `Tool…
8dd0276
…s/ssl/multissltests.py` (GH-138147) (#138263)

gh-138158: Use the `"data"` tarfile extraction filter in `Tools/ssl/multissltests.py` (GH-138147)

The `Tools/ssl/multissltests.py` script may extract a possibly untrusted tarball.
Since the script does not necessarily use Python 3.14 or later (where the `"data"`
filter became the default `tarfile` extraction filter), the user may theoretically
suffer from a path traversal attack.

Although the script should not be used in production and usually relies on downloading
trusted sources, the `"data"` extraction filter is now explicitly used wherever relevant.
(cherry picked from commit 31d3836)

Co-authored-by: Tommaso Bona <[email protected]>
hugovk pushed a commit that referenced this pull request Aug 31, 2025
@miss-islington @ParzivalHack
[3.14] gh-138158: Use the "data" tarfile extraction filter in `Tool…
b79bece
…s/ssl/multissltests.py` (GH-138147) (#138262)

Co-authored-by: Tommaso Bona <[email protected]>
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
@miss-islington @ParzivalHack @kumaraditya303
[3.14] pythongh-138158: Use the "data" tarfile extraction filter in…
b8e9bc5
… `Tools/ssl/multissltests.py` (pythonGH-138147) (python#138262)

Co-authored-by: Tommaso Bona <[email protected]>
lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
@ParzivalHack @lkollar
pythongh-138158: Use the "data" tarfile extraction filter in `Tools…
d93c021
…/ssl/multissltests.py` (python#138147)

The `Tools/ssl/multissltests.py` script may extract a possibly untrusted tarball.
Since the script does not necessarily use Python 3.14 or later (where the `"data"`
filter became the default `tarfile` extraction filter), the user may theoretically
suffer from a path traversal attack.

Although the script should not be used in production and usually relies on downloading
trusted sources, the `"data"` extraction filter is now explicitly used wherever relevant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AA-Turner AA-Turner AA-Turner left review comments
@picnixz picnixz picnixz approved these changes
@gpshead gpshead Awaiting requested review from gpshead gpshead is a code owner
@StanFromIreland StanFromIreland Awaiting requested review from StanFromIreland

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news tests Tests in the Lib/test dir topic-SSL

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@ParzivalHack @StanFromIreland @picnixz @AA-Turner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.