GeezerVison is showing github.com — gh-112887: Fix tarfile FilterError handling to skip member extraction by mattprodani · Pull Request #112954 · python/cpython
Conversation
mattprodani
commented
Dec 11, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
In tarfile library, if a FilterError is raised for a member during TarFile.extract() or TarFile.extractall() with errorlevel set to 0, a debugging message is correctly logged but the unsafe member is still extracted. Based on the documentation and a look at the code, it seems that the desired expectation with errorlevel=0 is to not raise an exception, but skip member extraction and log the error.
Updates tarfile to properly handle FilterError and skip extraction on unsafe members even when an exception is not raised.
This issue was reported on Python 3.11 and should likely be backported as it is a security issue.
From the docs:
When a filter refuses to extract a file, it will raise an appropriate exception, a subclass of FilterError. This will abort the extraction if TarFile.errorlevel is 1 or more. With errorlevel=0 the error will be logged and the member will be skipped, but extraction will continue.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
In `tarfile` library, FilterError with error_level set to 0 correctly logged a debugging
message but did not properly skip extraction of a member. Updates filter
functions to return None when a FilterError is seen, as stated in docs.
mattprodani
changed the title
gh-112887: Fix tarfile FilterError handling to skip member extraction
gh-112887: [WIP] Fix tarfile FilterError handling to skip member extraction
Dec 11, 2023
mattprodani
changed the title
gh-112887: [WIP] Fix tarfile FilterError handling to skip member extraction
gh-112887: Fix tarfile FilterError handling to skip member extraction
Dec 12, 2023
mattprodani reacted with hooray emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
ethanfurman
Awaiting requested review from ethanfurman
ethanfurman is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
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.