add exclusion patterns for tarfile-extractall-traversal#72
add exclusion patterns for tarfile-extractall-traversal#72cjenn-aviatrix wants to merge 1 commit intotrailofbits:mainfrom
Conversation
|
|
| - pattern-not: | | ||
| with tarfile.open(...) as $TAR: | ||
| ... | ||
| $TAR.extractall(..., filter=$FILTER, ...) |
There was a problem hiding this comment.
per https://docs.python.org/3/library/tarfile.html#default-named-filters we may still want to have failing behavior if filter is 'fully_trusted', or None prior to 3.14, but at least this forces it to be explicit
There was a problem hiding this comment.
Yes, I agree. I think we should still detect cases where filter is set to "fully_trusted", "tar", or None. Since the default will be "data" in Python 3.14 I think that's a reasonable acknowledgment that even "tar" has some security concerns. For example, it allows links to absolute paths or paths outside of the destination.
|
Thanks for the PR! To sum up, from python3.14 the default filter is
Another question: what happens if both filter and members args are provided:
|
|
My reading of members is that it simply filters some elements, so while it might be more deliberate than a blind extractall, it is not necessarily more safe. Compare with a single |
As per PEP706 the filter arg is used to prevent directory traversal