The injection issue
Yamale, a YAML schema validator, passed user-controlled schema strings to Python's eval with limited builtins, but an attacker could use Python reflection to recover builtins and execute arbitrary code. This could lead to remote code execution if an attacker can control the schema file, for example through a parameter injection flaw in a calling application.
jfrog.com
Published on jfrog.com
JFrog security research team (formerly Vdoo) has recently disclosed a code injection issue in Yamale, a popular schema validator for YAML that’s used by over 200 repositories. The issue has been assigned to CVE-2021-38305.
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 write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The application used Python's eval on untrusted input without adequate sanitisation, and the attempted restriction via limited builtins was insufficient because Python reflection can recover builtins.
Impact
An attacker who can control the schema file could execute arbitrary Python code, potentially leading to remote code execution if combined with a parameter injection flaw in a calling application.
What the attacker needed
Attacker controls schema file; or parameter injection in calling code
How it was found
- Identify that Yamale accepts a schema file via the -s/--schema command line parameter.
- Craft a malicious schema file that contains a Python expression using reflection to access builtins and execute arbitrary code.
- Supply the malicious schema file to Yamale, causing code execution.
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 write-up has not been written yet. The Original tab links to the source.
Yamale is a tool that checks YAML files against a schema. It used a Python function called eval to process the schema, which can run code. Even though the developers tried to restrict what eval could do, an attacker could still find a way to run their own commands by using Python's introspection features. This means if an attacker can supply the schema file, they can run arbitrary code on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.