The vulnerability exists in the jaraco.context.strip_first_component function, which is used as a filter during the extraction of tar files. This function's purpose is to remove the initial directory component from the file paths within the tar archive. The flaw is its failure to validate or sanitize path traversal sequences, such as ../.
The jaraco.context.tarball function directly utilized strip_first_component as the filter for tarfile.extractall. Consequently, when processing a malicious tar archive with a file path like dummy_dir/../../etc/passwd, the strip_first_component function would incorrectly process this to ../../etc/passwd. The extractall method would then proceed to write a file outside of the intended extraction directory, leading to a path traversal vulnerability.
The patch addresses this by introducing a new composite filter, _default_filter. This new filter combines Python's tarfile.data_filter, which is designed to prevent path traversal, with the original strip_first_component function. The tarball function was updated to use this safer, composite filter, thus mitigating the vulnerability. During an exploit of the unpatched version, a runtime profile would show calls to jaraco.context.tarball which in turn uses the vulnerable jaraco.context.strip_first_component filter.