The vulnerability, identified as GHSA-7wx9-6375-f5wh, exists in the picklescan library's scanning logic due to an incomplete blocklist. The core issue is that the scanner failed to recognize the module-level profile.run() function as dangerous, while it did block the class method profile.Profile.run().
The analysis of the patch in commit bf26452ae2e3204429762c2bb1aa9eacd40436bb reveals the fix. In src/picklescan/scanner.py, the UNSAFE_GLOBALS dictionary, which serves as the blocklist, was updated. The entry for the "profile" module was changed from {"Profile.run", "Profile.runctx"} to "*". This change ensures that any function from the profile module is now considered dangerous, effectively closing the bypass that allowed the use of profile.run().
The functions that utilize this UNSAFE_GLOBALS blocklist are the ones considered vulnerable. The advisory's proof-of-concept explicitly calls picklescan.scanner.scan_pickle_bytes to demonstrate the vulnerability. This function processes pickle data and, due to the incomplete blocklist, would incorrectly report a malicious pickle as safe. Another function, scan_file_path, is also present and tested in the same file, and it's highly probable that it uses the same flawed scanning logic.
Therefore, during exploitation (i.e., scanning a malicious pickle), a runtime profiler would show scanner.scan_pickle_bytes or scanner.scan_file_path executing and failing to detect the threat. The subsequent loading of this 'cleared' pickle by an application would lead to the execution of profile.run, resulting in arbitrary code execution.