security
deserialization
ai_generated
true
Remote code execution — unsafe deserialization of untrusted data
ID: security/deserialization-rce-untrusted-input
88%Fix Rate
92%Confidence
4Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Using pickle or Java ObjectInputStream on untrusted input allows arbitrary code execution.
genericWorkarounds
-
95% success Replace unsafe deserializers with safe formats like JSON or Protobuf
json.loads(data) instead of pickle.loads(data)
Sources: https://docs.python.org/3/library/pickle.html#restricting-globals
-
78% success If pickle is required, use RestrictedUnpickler with strict class allowlist
class SafeUnpickler(pickle.Unpickler): def find_class(self, module, name): ...
Sources: https://docs.python.org/3/library/pickle.html#restricting-globals
Dead Ends
Common approaches that don't work:
-
Validate the serialized data before deserializing
90% fail
The exploit triggers during deserialization itself, not after
-
Use a custom ObjectInputStream with class whitelist alone
65% fail
Gadget chains can use allowed classes to achieve code execution