The vulnerability, identified as GHSA-mjqp-26hc-grxg, allows a bypass of the picklescan security scanner. The root cause is an unhandled exception when processing ZIP archives containing files with CRC errors. The scanner uses a custom RelaxedZipFile class to handle ZIP files. My analysis of the patch between the vulnerable version 0.0.30 and the patched version 0.0.31 pinpointed the exact location of the fix.
The commit 28a7b4ef753466572bda3313737116eeb9b4e5c5 modifies the open method within src/picklescan/relaxed_zipfile.py. Previously, the method would return a standard zipfile.ZipExtFile object. When reading from this object, the underlying zipfile library performs a CRC check. If the check fails, it raises an exception, which picklescan did not handle gracefully, leading to the termination of the scan for that archive.
The patch mitigates this by creating the ZipExtFile object and then immediately monkey-patching its _expected_crc attribute to None. This effectively disables the CRC validation, preventing the exception from being thrown and allowing the scanner to proceed with analyzing the file's contents, even if the CRC is invalid. This ensures that potentially malicious files within a corrupted ZIP archive are not skipped.
Therefore, the RelaxedZipFile.open function is the direct source of the vulnerability, as it was responsible for setting up the file stream in a way that was susceptible to interruption by CRC errors.