Skip to main content

Module pickle

Module pickle 

Source
Expand description

Pickle opcode-stream validation ported from guard_core/handlers/_suspatterns_pickle.py (spec 4.0.2).

The reference walks a bounded 4096-byte window through the CPython pickle opcode dispatch (with class resolution, extension registry and persistent loading blocked). The walk answers exactly two questions: does the prefix before a candidate look like a valid opcode stream, and does the suffix after it reach a REDUCE/BUILD opcode without an error.

Functionsยง

pickle_global_candidate_is_injection
_pickle_global_candidate_is_injection: the prefix before the candidate must walk as a valid opcode stream and the suffix after the class-name group must reach REDUCE or BUILD.
pickle_prefix_is_opcode_stream
pickle_suffix_reaches_reduce_or_build