Unsafe YAML Deserialization
Overview
YAML loaders that support the full YAML specification (including !!python/object/apply:) can execute arbitrary code when parsing malicious YAML documents.
Python's yaml.load() without Loader=yaml.SafeLoader is the most common instance.
Malicious payload:
!!python/object/apply:os.system ["id"]
Remediation
- Python: Use
yaml.safe_load()oryaml.load(data, Loader=yaml.SafeLoader) - Ruby: Use
YAML.safe_load()instead ofYAML.load() - Node.js:
js-yamlusessafeLoad(default safe, butload()withunsafe=trueis dangerous)