Skip to content
RCE Disclosed report Intermediate

Unsafe yaml load can lead to remote code execution

The project used yaml.load() to parse YAML documents, which can construct arbitrary Python objects rather than only simple data types. An attacker who can supply a YAML document from an untrusted source could therefore cause arbitrary object construction, which the report frames as leading to remote code execution.

tarun_sec Follow

Originally disclosed on HackerOne

  • Triaged in 7 hours
  • Fixed in 22 hours
  • Disclosed after 17 days

TL;DR Yaml.load() has the ability to construct an arbitrary Python object. This is dangerous if you receive a YAML document from an untrusted source.

Proof of concept https://github.com/liberapay/liberapay.com/blob/master/liberapay/testing/vcr.py#L40

How do I fix it? Always use yaml.safe_load(). This function limits this ability to simple Python objects like integers or lists.

If you have any questions please comment on the report

best regards mrrobot2050

Impact

Yaml.load() has the ability to construct an arbitrary Python object. This is dangerous if you receive a YAML document from an untrusted source.

Attachments

Screenshot_2024-04-17_at_7.02.27_PM.png
Screenshot_2024-04-17_at_7.02.27_PM.png From the original on HackerOne

The original report as published on HackerOne, by tarun_sec. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The code called yaml.load() instead of a safe loader, so the parser was allowed to instantiate arbitrary Python objects described in the input.

Impact

If untrusted YAML reaches this code path, an attacker could achieve remote code execution; the report does not demonstrate this end to end and only points to the unsafe call.

What the attacker needed

Attacker-supplied YAML reaches the parser

The fix

The code should be changed to use yaml.safe_load() so that only simple Python objects such as integers and lists can be produced.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

YAML is a text format for configuration and data, similar to JSON. The unsafe loading function in the Python YAML library can build Python objects named in the document, not just plain values. If a program parses a YAML file from an untrusted source with that function, it is dangerous.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by tarun_sec

View all

3 more disclosed reports, best first.

More from Liberapay

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.