Untrusted data is not dynamically executed or unsafely deserialized

sec-002

Intent

Keep attacker-controlled data from becoming executable code, type metadata, or rich object graphs with dangerous behavior.

Applicability

Applies when the diff evaluates runtime code, deserializes non-trivial objects, loads YAML or similar rich formats, or uses deserialization APIs on external or semi-trusted input. Return unknown when loader choice is hidden behind wrappers.

What to inspect

eval-style APIs, object deserializers, unsafe YAML loaders, JNDI-like remote object lookups, and type-selection logic derived from input.

Pass criteria

External data is parsed as data through safe fixed-contract formats, and dynamic execution is avoided on untrusted paths.

Fail criteria

Untrusted data reaches eval, exec, new Function, unsafe object deserializers, remote lookup mechanisms that rehydrate objects, or attacker-controlled type metadata.

Do not flag

Trusted offline tooling with repository-owned input. Build-time code generation. Safe DTO binding. Serialization-only code with no unsafe deserialization path.

Confidence guidance

HIGH when the unsafe API and untrusted input path are directly visible. MEDIUM when trust level is inferred. LOW when loader choice is hidden.

Remediation

Use safe schema-driven formats, safe loaders, and explicit dispatch tables. Keep untrusted data as data, not code.

Pass example

payload = json.loads(body)

Fail example

payload = pickle.loads(body)

Sources

  • CWE Top 25 Most Dangerous Software Weaknesses report
  • Error Prone Bug Patterns Documentation documentation
  • OWASP Proactive Controls standard
  • OWASP Top 10 2021 and the 2025 Update Cycle; OWASP API Security Top 10 2023 report
  • Bandit Rule Documentation; Semgrep Python Security Rules documentation
  • Brakeman Warning Documentation documentation
  • PHP: The Right Way article
  • PHPStan/Psalm Rule Documentation documentation
  • Rails Security Guide guide
  • RuboCop, RuboCop Rails, RuboCop Performance Rule Docs documentation
  • Survive the Deep End: PHP Security article
  • OWASP NodeGoat; OWASP Node.js Security Cheat Sheet cheat-sheet