RCE vulnerability in Hyperledger Fabric SDK for Java
The Hyperledger Fabric SDK for Java used an unsafe YAML parser configuration in several classes, so parsing attacker-supplied YAML could instantiate arbitrary Java types. An attacker able to supply that YAML could achieve remote code execution.
- Triaged in 4 days
- Fixed in 53 days
- Paid in 53 days
- Disclosed after 2.5 years
Hyperledger Fabric SDK for Java version 2.0.0 and earlier does not configure its YAML parser to prevent the instantiation of arbitrary types, resulting in a remote code execution vulnerability.
In the following source code files and corresponding line number, an arbitrary file gets parsed by SnakeYAML which allows to construct a Java object of any type, leading to remote code execution.
- fabric-sdk-java/src/main/java/org/hyperledger/fabric/sdk/ChaincodeCollectionConfiguration.java line 121
- fabric-sdk-java/src/main/java/org/hyperledger/fabric/sdk/NetworkConfig.java line 301
- fabric-sdk-java/src/main/java/org/hyperledger/fabric/sdk/ChaincodeEndorsementPolicy.java line 241 and 262
- fabric-sdk-java/src/main/java/org/hyperledger/fabric/sdk/LifecycleChaincodeEndorsementPolicy.java line 228
Objects should be limited such as limiting to standard Java objects like List or Long by using SafeConstructor.
Yaml yaml = new Yaml(new SafeConstructor());
More info on Snake YAML can be found on the following url: https://bitbucket.org/asomov/snakeyaml/wiki/Documentation#markdown-header-loading-yaml
Impact
Remote Code Execution vulnerability
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 SDK instantiated SnakeYAML without a SafeConstructor, so the parser could construct objects of arbitrary Java types from untrusted YAML.
Impact
An attacker who can get malicious YAML parsed by the affected SDK classes could execute arbitrary code; the text does not describe any limiting defence.
What the attacker needed
Attacker-controlled YAML reaches the SDK
The fix
The YAML parser should be restricted to standard Java types by constructing it with SafeConstructor.
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 data. Some Java YAML libraries can be told to turn parts of that text into live Java objects, and if the text comes from an untrusted source, an attacker can choose which objects get created, which can lead to running their code. Here the library was left in that permissive mode.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.