Skip to content
RCE Advisory Intermediate CVE-2017-2809

ansible-vault Yaml Load Code Execution Vulnerability

The ansible-vault library decrypted a vault and then loaded its contents with the unsafe yaml.load API, which honours Python object directives. An attacker who could get a crafted vault opened could run arbitrary commands on the machine of whoever loaded it.

Cory Duplantis Follow

Originally disclosed on Cisco Talos

High 7.5 View original

An exploitable vulnerability exists in the yaml loading functionality of ansible-vault. A specially crafted vault can execute arbitrary python commands resulting in command execution.

Cory Duplantis, on Cisco Talos

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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 decrypted YAML was parsed with yaml.load, which constructs arbitrary Python objects instead of only plain data.

Impact

An attacker could execute arbitrary commands with the privileges of the user who loads the crafted vault, though the victim must open the file and the attack needs a valid vault password.

What the attacker needed

Attacker supplies a crafted vault file; victim loads it with the correct password

The fix

The unsafe loader should be replaced with yaml.safe_load so only plain data is parsed.

How it was found

  1. Create a vault file containing a Python object directive that runs a command.
  2. Load that vault through the ansible-vault API with the correct password.
  3. The command runs on the machine doing the loading.

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.

A vault is an encrypted file that is meant to hold secrets. The library decrypted the file and then handed the plain text to a YAML parser that can also build Python objects, so a line in the file could ask it to run a system command. Anyone who opened such a file would run the attacker's command on their own computer.

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 Cory Duplantis

View all

35 more disclosed reports, best first.

More from Cisco Talos

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.