The vulnerability in astral-tokio-tar (GHSA-6gx3-4362-rf54) was caused by the insufficient validation of PAX extensions in tar archives. The core issue, identified in the patch commit e5e0139cae4577eeedf5fc16b65e690bf988ce52, was the repeated use of the .filter_map(|res| res.ok()) pattern when processing PAX extension data. This code pattern silently discarded any errors that occurred during the parsing of these extensions, causing the library to ignore malformed data instead of rejecting the archive as invalid.
An attacker could exploit this by crafting a tar file with a malformed PAX extension for a file path, link path, or extended attribute. The vulnerable library would silently skip the malformed extension and fall back to the standard tar header, while a different, compliant tar parser might interpret the data differently, leading to a "parser differential" attack. This could result in outcomes like file path traversal or incorrect file permissions, depending on the behavior of the secondary parser.
The patch addresses this vulnerability by removing the error-suppressing code and instead explicitly handling potential errors. It replaces the .filter_map() calls with a for loop that uses the ? operator to propagate any Err results from the PAX extension iterator. This ensures that any malformed extension will now cause the parsing process to fail immediately, which is the correct and secure behavior.
The primary vulnerable functions are tokio_tar::entry::EntryFields::path_bytes, tokio_tar::entry::EntryFields::link_name_bytes, and tokio_tar::entry::EntryFields::set_xattrs, all of which are located in src/entry.rs and contained this flawed error-handling logic.