Skip to content

DEF CON 34 talks are here: 354 talks, summarized and searchable.

Browse DEF CON 34

Escaping the Tar Pit and Securing the Supply Chain

Kasimir Schulz

Supply ChainTalks50 minIntermediateOpen on YouTube ↗

Where

Talks
ShmooCon 2023

Duration

50 min

Explains a Python tarfile path traversal flaw and the large-scale GitHub scanning and patching effort it triggered.

Summary

The talk covers a path traversal flaw in the tarfile module that ships with CPython, triggered through extract and extractall calls. The bug was first reported in 2007, but for years the upstream discussion centred on whether it should be fixed at all, so no resolution landed. The speaker explains the mechanism: archive member names are joined to the destination path without validation, so an entry can write outside the intended directory.

To measure exposure, the team found that GitHub code search caps results, so they worked with GitHub directly and found millions of files importing tarfile across hundreds of thousands of repositories. Bandit could not easily match these multi-node patterns, so they built a custom scanner on Python's abstract syntax tree that adds parent references, looks back at surrounding context, and assigns confidence tiers. Among popular Python projects they reviewed by hand, a large share were vulnerable, and many tutorials demonstrated the unsafe pattern.

They patched affected code by checking that resolved member paths stay inside the target directory, applied edits through the syntax tree to preserve formatting, and opened tens of thousands of pull requests over roughly three months. Several notable projects merged the fixes. The takeaway is that a known flaw in a widely used library can persist for years, and automated scanning combined with coordinated patching can reach far beyond what manual review achieves.

Related talks