-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove backtracking from parsing tarfile members and headers #121285
Comments
* Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…thonGH-121286) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…thonGH-121286) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
|
…H-121286) (GH-123543) gh-121285: Remove backtracking when parsing tarfile headers (GH-121286) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
(I just added the labels that still require the backports and you could remove them one by one when you're done) |
…H-121286) (#123542) gh-121285: Remove backtracking when parsing tarfile headers (GH-121286) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…ers (pythonGH-121286) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…ers (pythonGH-121286) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…rs (pythonGH-121286) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…rs (pythonGH-121286) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…H-121286) (#123639) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…H-121286) (#123640) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
The CVE description contains:
but the test added to verify the fix does not cause/test the ReDoS. I mean, when you run the test with unpatched Python, it raises
Could you please help me understand how one of the regexes (fox example: |
@frenzymadness Apologies for the confusion, not all of the regular expressions in the PR have issues with backtracking. The regex you mention was replaced to process the entire tar header block in one pass rather than multiple passes. |
…-121286) (#123642) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…-121286) (#123641) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…e headers (pythonGH-121286) (python#123642) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]>
…e headers (pythonGH-121286) (python#123642) * Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]> Co-authored-by: Lumír Balhar <[email protected]>
Patch for Python 3.8 applies more or less painlessly on the 3.6 branch as well. |
* Remove backtracking when parsing tarfile headers * Rewrite PAX header parsing to be stricter * Optimize parsing of GNU extended sparse headers v0.0 (cherry picked from commit 34ddb64) Co-authored-by: Seth Michael Larson <[email protected]> Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Gregory P. Smith <[email protected]> Fixes: bsc#1230227 (CVE-2024-6232) Fixes: gh#python#121285 From-PR: gh#python/cpython!123642 Patch: CVE-2024-6232-ReDOS-backtrack-tarfile.patch
Bug description:
Today the
tarfile
module parsing of header values allows for backtracking when parsing header values. Headers have a well-known format that doesn't require backtracking to parse reliably, the new method of parsing will only require a single pass over a byte stream.CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: