security security_error ai_generated true

java.io.ObjectInputStream: Deserialization of untrusted data

ID: security/deserialization-rce

Also available as: JSON · Markdown
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
any active

Root Cause

Deserializing untrusted data (Java ObjectInputStream, Python pickle, YAML) enables RCE.

generic

Workarounds

  1. 92% success Use safe serialization formats (JSON, protobuf) instead
    Replace pickle.loads with json.loads; use Jackson instead of ObjectInputStream
  2. 95% success Use yaml.safe_load instead of yaml.load
    yaml.safe_load(data) blocks arbitrary Python object construction

Dead Ends

Common approaches that don't work:

  1. Add a class whitelist to ObjectInputStream 65% fail

    Whitelist can be bypassed through gadget chains in allowed classes.

  2. Validate serialized data before deserializing 85% fail

    Validation requires deserialization first, creating a chicken-and-egg problem.