cpython icon indicating copy to clipboard operation
cpython copied to clipboard

gh-121285: Remove backtracking when parsing tarfile headers

Open sethmlarson opened this issue 1 year ago • 7 comments

This removes all instances of backtracking from parsing tarfile headers, specifically hdrcharset, PAX, and GNU sparse headers.

  • Issue: gh-121285

sethmlarson avatar Jul 02 '24 18:07 sethmlarson

@sethmlarson Did you mean to add the "Needs backport to 3.x" labels rather than the "3.x" ones?

hugovk avatar Jul 02 '24 18:07 hugovk

@hugovk Yes! Selected the wrong range of tags, my bad.

sethmlarson avatar Jul 02 '24 18:07 sethmlarson

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.

bedevere-app[bot] avatar Jul 02 '24 19:07 bedevere-app[bot]

@ethanfurman Type hints removed in https://github.com/python/cpython/pull/121286/commits/0b5341b66a8cea891608fc4deab026aaa14a1307. I have made the requested changes; please review again

sethmlarson avatar Jul 02 '24 19:07 sethmlarson

Thanks for making the requested changes!

@ethanfurman: please review the changes made to this pull request.

bedevere-app[bot] avatar Jul 02 '24 19:07 bedevere-app[bot]

@gpshead, should we add new tests?

ethanfurman avatar Jul 02 '24 19:07 ethanfurman

@gpshead, should we add new tests?

A regression test would be "nice" but isn't strictly required as this is a CPU DoS prevention. The existing functionality tests continuing to pass is the important part.

If we adapted the proof of concept code or example file from the reporter into a regression test, that is effectively giving away an exploit tool. It is generally considered nicer to wait a while after a release before doing that.

Such tests would be needed for each of the covered tar formats, with the expected result being a tarfile.ReadError within a short amount of time rather than hanging.

gpshead avatar Jul 03 '24 22:07 gpshead

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.

bedevere-app[bot] avatar Jul 05 '24 19:07 bedevere-app[bot]

I have made the requested changes; please review again

sethmlarson avatar Jul 09 '24 17:07 sethmlarson

Thanks for making the requested changes!

@ethanfurman, @gpshead: please review the changes made to this pull request.

bedevere-app[bot] avatar Jul 09 '24 17:07 bedevere-app[bot]

@gpshead @ethanfurman @serhiy-storchaka This PR is still awaiting a final review, if you have time please take a look :)

sethmlarson avatar Aug 06 '24 20:08 sethmlarson

Thanks @sethmlarson for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13. 🐍🍒⛏🤖

miss-islington-app[bot] avatar Aug 31 '24 22:08 miss-islington-app[bot]

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

bedevere-app[bot] avatar Aug 31 '24 22:08 bedevere-app[bot]

Sorry, @sethmlarson and @gpshead, I could not cleanly backport this to 3.11 due to a conflict. Please backport using cherry_picker on command line.

cherry_picker 34ddb64d088dd7ccc321f6103d23153256caa5d4 3.11

miss-islington-app[bot] avatar Aug 31 '24 22:08 miss-islington-app[bot]

GH-123543 is a backport of this pull request to the 3.12 branch.

bedevere-app[bot] avatar Aug 31 '24 22:08 bedevere-app[bot]

Sorry, @sethmlarson and @gpshead, I could not cleanly backport this to 3.10 due to a conflict. Please backport using cherry_picker on command line.

cherry_picker 34ddb64d088dd7ccc321f6103d23153256caa5d4 3.10

miss-islington-app[bot] avatar Aug 31 '24 22:08 miss-islington-app[bot]

Sorry, @sethmlarson and @gpshead, I could not cleanly backport this to 3.9 due to a conflict. Please backport using cherry_picker on command line.

cherry_picker 34ddb64d088dd7ccc321f6103d23153256caa5d4 3.9

miss-islington-app[bot] avatar Aug 31 '24 22:08 miss-islington-app[bot]

Sorry, @sethmlarson and @gpshead, I could not cleanly backport this to 3.8 due to a conflict. Please backport using cherry_picker on command line.

cherry_picker 34ddb64d088dd7ccc321f6103d23153256caa5d4 3.8

miss-islington-app[bot] avatar Aug 31 '24 22:08 miss-islington-app[bot]

GH-123639 is a backport of this pull request to the 3.11 branch.

bedevere-app[bot] avatar Sep 03 '24 14:09 bedevere-app[bot]

GH-123639 is a backport of this pull request to the 3.11 branch.

bedevere-app[bot] avatar Sep 03 '24 14:09 bedevere-app[bot]

GH-123640 is a backport of this pull request to the 3.10 branch.

bedevere-app[bot] avatar Sep 03 '24 14:09 bedevere-app[bot]

GH-123641 is a backport of this pull request to the 3.9 branch.

bedevere-app[bot] avatar Sep 03 '24 14:09 bedevere-app[bot]

GH-123642 is a backport of this pull request to the 3.8 branch.

bedevere-app[bot] avatar Sep 03 '24 14:09 bedevere-app[bot]

Backports have been created.

sethmlarson avatar Sep 03 '24 15:09 sethmlarson