| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Fix of a Path Traversal vulnerability in a test script in multissltests.py
Sorry, something went wrong.
There was a problem hiding this comment.
It seems you have several unrelated whitespace changes; please revert.
A
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
Sorry, something went wrong.
Reverted the unrelated whitespace changes
|
I have made the requested changes; please review again |
Sorry, something went wrong.
|
Thanks for making the requested changes! @AA-Turner: please review the changes made to this pull request. |
Sorry, something went wrong.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
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. |
Sorry, something went wrong.
Remove additional whitespace Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
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.
There was a problem hiding this comment.
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.
|
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?). |
Sorry, something went wrong.
Hey @picnixz, 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👍 |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
No worries. And i was running everything with Python 3.13.3👍 |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
Hey @picnixz, Thanks again for the opportunity to contribute :) |
Sorry, something went wrong.
|
Thanks @ParzivalHack for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
Sorry, something went wrong.
…/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 <piergeolo@gmail.com>
…/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 <piergeolo@gmail.com>
|
GH-138262 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
|
GH-138263 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
…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 <piergeolo@gmail.com>
… `Tools/ssl/multissltests.py` (pythonGH-138147) (python#138262) Co-authored-by: Tommaso Bona <piergeolo@gmail.com>
…/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.
| Back | FazBrowse Home | New Git URL |
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.