Skip to main content
Founding Partner + 7-Day Trial
Tier B Enterprise Fleet · 12-Language Immunity EngineAutoExtinguish: true (4-Gate Vericoding)

Scanner severity: MEDIUM · AutoExtinguish: true across 11 languages; AutoExtinguish: false in Go (DisallowUnknownFields requires deliberate API contract confirmation via ciphermap mcp).

Commercial boundary: ciphermap immunity scan, immunity extinguish --apply, immunity attest (CycloneDX 1.6 CISA IBOM & OpenVEX 0.2.0), and ciphermap mcp require Tier B Enterprise Fleet. Offline proof and IBOM verification (--verify-proof, attest --verify) and the ciphermap demo sandbox run Free.

Back to docs
IMM-DESER-001Rule-dependent (HIGH–CRITICAL)CISA Secure-by-Design Pledge · CWE-20 · NIST SP 800-53 Rev. 5 (SI-10)

Unsafe Polymorphic Deserialization or Permissive Boundary Decoding

Severity: Rule-dependent (HIGH–CRITICAL)

Deserializing untrusted payloads with polymorphic gadget-capable formats (Ruby Marshal, Python pickle, unsafe YAML, PHP unserialize, Java ObjectInputStream, .NET BinaryFormatter, Swift NSKeyedUnarchiver without NSSecureCoding) or permissive boundary decoders missing unknown-field rejection exposes services to remote code execution, mass-assignment, and schema smuggling across Go, TypeScript, JavaScript, Python, Java, Kotlin, C#, Rust, C/C++, Ruby, PHP, and Swift. Scanner base severity for IMM-DESER-001 is MEDIUM; AutoExtinguish is enabled across 11 languages, while Go json.NewDecoder DisallowUnknownFields() defaults to AutoExtinguish: false so schema strictness is verified deliberately.

Remediation checklist

  • Go & Rust: call dec.DisallowUnknownFields() on boundary encoding/json.Decoder instances in Go and annotate boundary request structs with #[serde(deny_unknown_fields)] plus bounded bincode options in Rust.
  • TypeScript & JavaScript: replace node-serialize / unsafe js-yaml schemas with JSON.parse + strict schema validation (e.g. zod.strict()) or FAILSAFE_SCHEMA; Python: replace pickle.loads and unsafe yaml.load with yaml.safe_load(data) or typed JSON models.
  • Java & Kotlin: enforce strict allowlist ObjectInputFilter before ObjectInputStream.readObject() or use typed Jackson/kotlinx.serialization without polymorphic default typing; C#: replace BinaryFormatter and TypeNameHandling.All with System.Text.Json typed DTOs.
  • C/C++: decode untrusted bytes with length-validated schema parsers (Protobuf/FlatBuffers) rather than raw struct casts; Ruby: replace Marshal.load, YAML.unsafe_load, and permissive Oj.load with YAML.safe_load(data, permitted_classes: []) or Oj.load(data, mode: :strict); PHP: pass ['allowed_classes' => false] to unserialize() or use json_decode(); Swift: enforce NSSecureCoding via NSKeyedUnarchiver.unarchivedObject(ofClass:from:) or typed Codable.

Illustrative Code Examples

These fragments explain migration direction. They are not complete applications or compiler-verified patches for your project.

Vulnerable — gadget deserializers & permissive boundary decoders (Go / Ruby / PHP)

terminal · zsh
// Go: permissive boundary JSON decoder accepts unknown fields
err := json.NewDecoder(r.Body).Decode(&dst)

# Ruby: arbitrary object gadget instantiation
session = Marshal.load(raw_cookie)

// PHP: POP-chain object injection via unserialize
$prefs = unserialize($_COOKIE['prefs']);

Remediated — strict schema & gadget-free decoding

terminal · zsh
// Go: bounded + DisallowUnknownFields
dec := json.NewDecoder(http.MaxBytesReader(w, r.Body, 1<<20))
dec.DisallowUnknownFields()
err := dec.Decode(&dst)

# Ruby: safe_load with zero custom classes permitted
session = YAML.safe_load(raw_cookie, permitted_classes: [], aliases: false)

// PHP: object instantiation explicitly disabled
$prefs = unserialize($_COOKIE['prefs'], ['allowed_classes' => false]);

Preview remediation proposals

Preview proposed changes free with ciphermap fix . --dry-run --offline --no-telemetry. Eligibility depends on the installed build, call shape, module format, and migration context. The bundled RSA fixture has a classical key-size candidate; that does not make it post-quantum secure. Persisted digests and unsupported contexts may be declined. Applying supported candidates requires an entitlement, explicit verifier consent, and the required project tools. Review the actual verification result before adopting a change.

View DevSecOps pricing

Other rule families