criticalUser input reaching your database or shell

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.

pickle.loads on the request body
obj = pickle.loads(request.data)

The smallest fix

minimal patch
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 only

The better fix

If you have a few more minutes, this is the approach that holds up as the app grows.

safe alternative
# 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.

In [the file] at line [the line number] external data is decoded unsafely: [the flagged code]. Replace pickle/marshal with JSON plus a pydantic model, yaml.load with yaml.safe_load, and eval/exec with an explicit parser or a dispatch table. Add a test that sends a payload containing a function call and asserts it is rejected.

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.

Further reading