Denial of Service Vulnerability in yaml-cpp
Summary
CVE-2018-20574: The SingleDocParser::HandleFlowMap function in yaml-cpp (aka LibYaml-C++) 0.6.2 allows remote attackers to cause a denial of service (stack consumption and application crash) via a crafted YAML file. Affects yaml-cpp across 2 version ranges.
< 0.6.3-1
< 562aefc114938e388457e6a531ed7b54d9dc1b62
Fixed in 0.6.3-1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
yaml-cpp is an open-source library for parsing and emitting YAML files. It is commonly used in various applications to handle YAML data. The library allows developers to read and write YAML files, making it easier to work with structured data. However, a vulnerability has been discovered in yaml-cpp version 0.6.2, which can lead to a denial of service attack.
Vulnerability Detail
The vulnerability, identified as CVE-2018-20574, exists in the SingleDocParser::HandleFlowMap function of yaml-cpp. An attacker can exploit this vulnerability by providing a specially crafted YAML file. When the vulnerable function attempts to parse the malicious YAML file, it consumes excessive stack memory, leading to a stack overflow and subsequent application crash. This vulnerability can be exploited remotely, potentially causing disruption to affected systems.
How To Fix
Minimum fixed version
0.6.3-1
This is the first release that contains the fix.
sudo apt-get install --only-upgrade yaml-cpp
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a workaround, developers can implement input validation to detect and reject malicious YAML files. By validating the structure and content of YAML files before parsing them with yaml-cpp, developers can prevent the vulnerable function from being exploited. Here is an example of how input validation can be implemented in C++ using yaml-cpp:
#include <yaml-cpp/yaml.h>
bool validateYaml(const std::string& yamlData) {
try {
YAML::Node node = YAML::Load(yamlData);
// Perform additional validation checks
// ...
return true;
} catch (const YAML::Exception& e) {
// Handle validation failure
// ...
return false;
}
}
Conclusion
In conclusion, the yaml-cpp library is vulnerable to a denial of service attack due to a stack consumption issue in the SingleDocParser::HandleFlowMap function. To mitigate this vulnerability, it is crucial to update yaml-cpp to version 0.6.3-1 or later. Additionally, implementing input validation can provide an extra layer of protection against malicious YAML files. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for yaml-cpp →
FAQ
yaml-cpp is an open-source library for parsing and emitting YAML files. It provides a convenient way for developers to work with structured data in YAML format.
The vulnerability allows remote attackers to cause a denial of service by crashing the application using a specially crafted YAML file. This can lead to disruption of affected systems.
To fix this vulnerability, update yaml-cpp to version 0.6.3-1 or later. Ensure that you are using the latest version of the library in your applications.
Yes, you can implement input validation to detect and reject malicious YAML files. By validating the structure and content of YAML files before parsing them with yaml-cpp, you can mitigate the risk of this vulnerability.
You can find more information about this vulnerability in the official CVE-2018-20574 advisory or by visiting the Vulert Playground at Vulert Scanner.
Related vulnerabilities
Recent vulnerabilities recorded for yaml-cpp.