sdk/python/Archives/PyTarfile
Archives

PyTarfile

The tarfile module. extractall() and extract() follow archive entry paths as-is — path-traversal sink (zip slip) when the archive is user-supplied and extractall's filter= argument is not set to a safe filter. Python 3.12 changed the default to 'data'.

2 sinks
Taint flow0 sources 2 sinks
Sinks — dangerous call
.extractall()
.extract()

Sinks

.extractall()Sink
#
Signature
TarFile.extractall(path='.', members=None, *, numeric_owner=False, filter=None) -> None

Extracts all entries. Zip-slip sink when members comes from a hostile archive and filter is unset.

.extract()Sink
#
Signature
TarFile.extract(member, path='', *, set_attrs=True, numeric_owner=False, filter=None) -> None

Extracts a single entry. Same path-traversal risk as extractall.

Other Methods

.open()Neutral
#
Signature
tarfile.open(name=None, mode='r', fileobj=None, ...) -> TarFile

Opens a tar archive. Neutral; extract() is where traversal happens.

Fully-Qualified Names

FQNField
tarfilefqns[0]
tarfile.TarFilefqns[1]

Wrong FQN → 0 findings. Verify with: change fqns to garbage → must produce 0 results.

Import

rule.py
from codepathfinder.go_rule import PyTarfile