The vulnerability GHSA-p9w7-82w4-7q8m lies in the picklescan library's failure to detect a malicious pickle payload that uses the lib2to3.pgen2.pgen.ParserGenerator.make_label function. This function, part of Python's standard library, can be leveraged to execute arbitrary code.
The root cause of the vulnerability in picklescan is an incomplete blocklist of dangerous functions. The library maintains a dictionary of known dangerous globals (dangerous_globals in src/picklescan/scanner.py) that should not be present in a safe pickle file. Before the patch, lib2to3.pgen2.pgen.ParserGenerator.make_label was not on this list.
An attacker can create a pickle file that, when loaded by pickle.load(), will execute the __reduce__ method of a specially crafted class. This __reduce__ method can be designed to return the ParserGenerator.make_label function and arguments that form a malicious command. When pickle.load() processes this, it executes the function, leading to remote code execution.
The provided patch addresses this by adding lib2to3.pgen2.pgen.ParserGenerator.make_label to the dangerous_globals dictionary in src/picklescan/scanner.py. This ensures that picklescan will now correctly identify pickle files attempting to use this function and flag them as malicious.
Therefore, for a security engineer, the key runtime indicator of an attempted exploit of this vulnerability would be the execution of the lib2to3.pgen2.pgen.ParserGenerator.make_label function originating from a pickle.load() operation. While the vulnerability is in picklescan, the function to monitor for during an active exploit is the one from the standard library.