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 →
- Replace pickle with a data-only format: JSON with schema validation (pydantic), or protobuf.
- If pickle is unavoidable between trusted services, sign the payload with HMAC and verify before loading.
- Search the codebase for similar sinks:
pickle.loads,yaml.loadwithoutSafeLoader, JavaObjectInputStream,Marshal.loadin Ruby. - 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.
More on Vulnerability Management and OWASP
A pentest report shows SQL injection in a search endpoint of a Java service. How do you handle it end to end?BeginnerA scanner reports 4,000 open CVEs across 300 images. The team can fix maybe 100 a month. How do you prioritise?IntermediateA user reports they can see another customer's invoice by changing the ID in the URL. What do you do?BeginnerA webhook feature lets users enter a URL, and a pentester used it to read the cloud metadata endpoint. How do you fix it?AdvancedA team still runs Log4j 2.14 in an internal service and says it is not internet-facing. How do you respond?IntermediateA security review finds passwords stored as unsalted MD5 hashes. How do you migrate without forcing every user to reset?Advanced