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-112887: Fix tarfile FilterError handling to skip member extraction by mattprodani · Pull Request #112954 · python/cpython

Conversation

@mattprodani

@mattprodani mattprodani commented Dec 11, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

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.

  • Issue: [CVE-2025-4435] tarfile still extracts problematic files when filter is set and errorlevel is 0 #112887

Sorry, something went wrong.

Uh oh!

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

All reactions
mattprodani added 2 commits December 1, 2023 15:13
@mattprodani
Fix tarfile FilterError handling to skip member extraction
c981c3d
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
add and fix tests for filtererror
191998a
@bedevere-app bedevere-app Bot mentioned this pull request Dec 11, 2023
[CVE-2025-4435] tarfile still extracts problematic files when filter is set and errorlevel is 0 #112887
Closed
@mattprodani 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
mattprodani force-pushed the safetar branch from 3243699 to c981c3d Compare December 11, 2023 21:53
@mattprodani 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
@blurb-it
📜🤖 Added by blurb_it.
9812823
@mattprodani
mattprodani marked this pull request as ready for review December 12, 2023 20:37
@mattprodani
mattprodani requested a review from ethanfurman as a code owner December 12, 2023 20:37
@bedevere-app bedevere-app Bot added the awaiting review label Dec 12, 2023
@encukou

encukou commented Jun 4, 2025

Copy link
Copy Markdown
Member

Thank you for the fix. I included it, in a “Ship of Theseus” style, in #135037 which fixes a few other security issues as well.

I forgot to include you in the Git authorship metadata. I apologize for that. You're credited in What's New though: https://docs.python.org/3.14/whatsnew/3.14.html#tarfile

mattprodani reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

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

@encukou encukou closed this Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ethanfurman 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

Labels

awaiting review

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.

2 participants

@mattprodani @encukou
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.