Untrusted Data Passed to pickle, yaml.load, eval or exec
Data that came from outside is decoded with a format that can execute code.
Why it matters
pickle and marshal serialise Python objects, including instructions to call functions, and yaml's full loaders can build arbitrary objects. eval and exec run whatever they are given. For data from a request, a file upload or a queue, JSON or yaml.safe_load carries the same information without the ability to run code.
What it looks like
This is the shape of code that triggers the rule. AI tools produce it because it works, and nothing tells them it is unsafe.
obj = pickle.loads(request.data)The smallest fix
import json
data = json.loads(request.data) # instead of pickle.loads(request.data)
config = yaml.safe_load(uploaded_text) # instead of yaml.load(..., Loader=yaml.Loader)
value = ast.literal_eval(text) # instead of eval(text), for literals onlyThe better fix
If you have a few more minutes, this is the approach that holds up as the app grows.
# If you need typed objects, validate the JSON with pydantic or
# marshmallow. If a pickle file truly must be loaded, it should come
# from storage only your own code writes to, never from a user.Let your AI tool fix it
When the scanner finds this in your project, it fills in the file and line for you. This is the prompt it gives you to paste into Claude Code, Cursor or whatever you use.
How to check the fix worked
1. Send a payload that is not valid JSON/YAML data and confirm a 400. 2. Confirm a normal payload still works end to end.