Loading YAML in Java client can lead to command execution
The Kubernetes Java client library deserialised YAML using SnakeYAML with its class-instantiation feature left enabled, so a crafted YAML document could create arbitrary Java objects. An attacker who could supply YAML to the library could therefore run arbitrary code during deserialisation.
- Triaged in 4 days
- Fixed in 4 months
- Paid in 3 months
- Disclosed after 4 months
Summary by the program
The io.kubernetes.client.util.Yaml file in the Kubernetes client library for Java uses a popular library SnakeYAML to serialize and deserialize YAML. The library has a feature which makes it possible to initiate instances of Java classes by using a YAML tag like !!some.Class [ "argument1" ]. More info about this feature can be found in the docs. This can be used to execute arbitrary code during the deserialization of a YAML file.
Summary by the researcher
I wrote a small post about this report on my blog, you can find it here: https://j0vsec.com/post/cve-2021-25738/
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
Likely the YAML parser was used in its default mode, which allows YAML tags to instantiate arbitrary Java classes during deserialisation.
What the attacker needed
Attacker-supplied YAML is parsed by the client
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 often used for configuration files. Some YAML parsers can be told, inside the file itself, to build a particular programming object, and if that object is dangerous, simply reading the file can run the attacker's code. Here the Java Kubernetes client read YAML with that feature switched on, so a malicious file was enough.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.