Interview Prep/DevSecOps/Vulnerability Management and OWASP

A developer uses `pickle.loads()` on data received from an API. What is the risk and what do you recommend?

IntermediateScenarioVulnerability Management and OWASP
Answer

Situation read → Insecure deserialization (now folded into OWASP A08, Software and Data Integrity Failures). Unpickling attacker data gives remote code execution.

What I'd do →

  1. Replace pickle with a data-only format: JSON with schema validation (pydantic), or protobuf.
  2. If pickle is unavoidable between trusted services, sign the payload with HMAC and verify before loading.
  3. Search the codebase for similar sinks: pickle.loads, yaml.load without SafeLoader, Java ObjectInputStream, Marshal.load in Ruby.
  4. Enable Bandit rules B301 and B506 in CI.
    bandit -r src/ -t B301,B506
    

Why → Deserialisers that build arbitrary objects execute code during loading; validation afterwards is too late.

Interview tip → yaml.safe_load versus yaml.load is a frequent follow-up.

All DevSecOps questions Roadmap: Security in the pipeline

More on Vulnerability Management and OWASP