Python Pickle Extended Deserialization
Overview
Beyond basic pickle.loads(), Python has several other insecure deserialization mechanisms:
shelve(backed by pickle)marshal.loads()(bytecode deserialization)pickletools- HTTP APIs passing pickled data in cookies or request bodies
Remediation
- Replace with
json,msgpack, orprotobuf - If using shelve/pickle for caching, ensure data source is trusted and server-controlled
- Never accept serialized Python objects from HTTP clients