Python 3.12+tarfilefunction
tarfile.fully_trusted_filter()
extraction filters
The 'fully_trusted' extraction filter: it returns the member unchanged — the archive is trusted completely.
Syntax
tar.extractall(path, filter='fully_trusted')
This is how tarfile always extracted before Python 3.14, and on 3.12–3.13 calling extractall() without filter emits a DeprecationWarning precisely because it uses this filter. With it, '../x', absolute paths and links pointing outside write anywhere — that is path traversal. Use it only for archives you created yourself.
Examples
import tarfile
m = tarfile.TarInfo('../outside.txt')
print(tarfile.fully_trusted_filter(m, 'out') is m) # → True — член не тронут
try:
tarfile.data_filter(m, 'out')
except tarfile.OutsideDestinationError:
print('data не пустит наружу') # → data не пустит наружу
See also
Open in the full glossarydocs.python.orgReport an inaccuracy