Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

The Dangers of pickle and yaml.load

Deserialization vulnerabilities arise when applications reconstruct objects from untrusted data.

In Python, this is particularly dangerous with:

pickle: Arbitrary Code Execution by Design

pickle is not secure against untrusted input.

import pickle

data = request.data
obj = pickle.loads(data)

An attacker can craft a malicious pickle payload that executes arbitrary system commands during deserialization.

The pickle protocol allows objects to define how they are reconstructed, including calling arbitrary callables.

If untrusted users control pickled data, they control code execution.

Unsafe YAML Loading

Older versions of PyYAML allowed this:

import yaml

data = yaml.load(user_input)

Without specifying a safe loader, this could instantiate arbitrary Python objects.

Secure Alternative

yaml.safe_load(user_input)

What to Look for in Audits

Attackers upload a “configuration file” that is actually a malicious object constructor.