GHSA-cgx6-hpwq-fhv5: Nokogiri Integer Overflow Or Wraparound Vulnerability
HIGHGHSA-cgx6-hpwq-fhv5 is a HIGH (CVSS 8.6) integer overflow or wraparound vulnerability (CWE-190: Integer Overflow or Wraparound) affecting Nokogiri libraries in the RubyGems ecosystem. The issue involves integer overflow or wraparound in libxml2 affects nokogiri. Remediation is available by upgrading affected packages to version 1.13.5.
GHSA-cgx6-hpwq-fhv5 at a Glance
Security Impact
CVSS: 8.6
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H).
How to Fix GHSA-cgx6-hpwq-fhv5
To remediate this vulnerability, upgrade all affected Nokogiri dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade nokogiri to 1.13.5
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for nokogiri
How to Check if You Are Affected
To determine whether your application is affected by GHSA-cgx6-hpwq-fhv5, inspect your project dependencies for Nokogiri:
inspect dependencies for nokogiri
Analyze the terminal output to locate any version of Nokogiri in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.13.5), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. In Nokogiri, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-cgx6-hpwq-fhv5 Affected Nokogiri Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nokogiri
|
RubyGems |
< 1.13.5
|
1.13.5
|
References
Frequently Asked Questions
What is GHSA-cgx6-hpwq-fhv5?
Which Nokogiri versions are affected?
What version fixes GHSA-cgx6-hpwq-fhv5?
Is nokogiri affected?
What is the CVSS score of GHSA-cgx6-hpwq-fhv5?
What CWE is associated with GHSA-cgx6-hpwq-fhv5?
How can I check RubyGems dependencies for GHSA-cgx6-hpwq-fhv5?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-cgx6-hpwq-fhv5",
"modified" : "2022-05-18T20:06:48Z",
"published" : "2022-05-18T20:06:48Z",
"aliases" : [ ],
"summary" : "Integer Overflow or Wraparound in libxml2 affects Nokogiri",
"details" : "### Summary\n\nNokogiri v1.13.5 upgrades the packaged version of its dependency libxml2 from v2.9.13 to [v2.9.14](https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.9.14).\n\nlibxml2 v2.9.14 addresses [CVE-2022-29824](https://nvd.nist.gov/vuln/detail/CVE-2022-29824). This version also includes several security-related bug fixes for which CVEs were not created, including a potential double-free, potential memory leaks, and integer-overflow.\n\nPlease note that this advisory only applies to the CRuby implementation of Nokogiri `< 1.13.5`, and only if the _packaged_ libraries are being used. If you've overridden defaults at installation time to use _system_ libraries instead of packaged libraries, you should instead pay attention to your distro's `libxml2` and `libxslt` release announcements.\n\n\n### Mitigation\n\nUpgrade to Nokogiri `>= 1.13.5`.\n\nUsers who are unable to upgrade Nokogiri may also choose a more complicated mitigation: compile and link Nokogiri against external libraries libxml2 `>= 2.9.14` which will also address these same issues.\n\n\n### Impact\n\n#### libxml2 [CVE-2022-29824](https://nvd.nist.gov/vuln/detail/CVE-2022-29824)\n\n- **CVSS3 score**:\n - Unspecified upstream\n - Nokogiri maintainers evaluate at 8.6 (High) ([CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H](https://www.first.org/cvss/calculator/3.1#CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H)). Note that this is different from the CVSS assessed by NVD.\n- **Type**: Denial of service, information disclosure\n- **Description**: In libxml2 before 2.9.14, several buffer handling functions in buf.c (xmlBuf*) and tree.c (xmlBuffer*) don't check for integer overflows. This can result in out-of-bounds memory writes. Exploitation requires a victim to open a crafted, multi-gigabyte XML file. Other software using libxml2's buffer functions, for example libxslt through 1.1.35, is affected as well.\n- **Fixed**: https://gitlab.gnome.org/GNOME/libxml2/-/commit/2554a24\n\nAll versions of libml2 prior to v2.9.14 are affected.\n\nApplications parsing or serializing multi-gigabyte documents (in excess of INT_MAX bytes) may be vulnerable to an integer overflow bug in buffer handling that could lead to exposure of confidential data, modification of unrelated data, or a segmentation fault resulting in a denial-of-service.\n\n\n### References\n\n- [libxml2 v2.9.14 release notes](https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.9.14)\n- [CVE-2022-29824](https://nvd.nist.gov/vuln/detail/CVE-2022-29824)\n- [CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer](https://cwe.mitre.org/data/definitions/119.html)\n\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "nokogiri"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.13.5"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-cgx6-hpwq-fhv5"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-29824"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/sparklemotion/nokogiri"
}, {
"type" : "WEB",
"url" : "https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.9.14"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-190" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-05-18T20:06:48Z",
"nvd_published_at" : null
}
}