You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False negative: B202 unsafe tarfile.extract() not detected #1392
B202 is intended to detect unsafe tar extraction patterns (CWE-22), but the current implementation only checks for extractall calls and misses unsafe extract usage.
Reproduction steps
cat > /tmp/repro_b202_extract_fn.py <<'PY'import tarfileimport tempfilefrom pathlib import Pathdef unsafe_archive_handler(filename): target_dir = Path(tempfile.mkdtemp()) tar = tarfile.open(filename) for member in tar.getmembers(): # Vulnerable: no validation of member.name/linkname tar.extract(member, path=target_dir) tar.close()PY
bandit -r /tmp/repro_b202_extract_fn.py -t B202
Expected behavior
B202 should also detect an unsafe tarfile.extract() usage, not only extractall().
Activity