Skip to main content

CVE-2022-50999 — Integer Overflow or Wraparound in nokogiri

HIGH

Integer Overflow or Wraparound in libxml2 affects Nokogiri

Published May 18, 2022Updated August 27, 2026Source: OSV

Does your project use an affected nokogiri version?

Paste your Gemfile.lock to check it for CVE-2022-50999 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my Gemfile.lock

Summary

Summary

Nokogiri v1.13.5 upgrades the packaged version of its dependency libxml2 from v2.9.13 to v2.9.14.

libxml2 v2.9.14 addresses 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.

Please 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.

Mitigation

Upgrade to Nokogiri >= 1.13.5.

Users 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.

Impact

libxml2 CVE-2022-29824

  • CVSS3 score:
  • Type: Denial of service, information disclosure
  • 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.
  • Fixed: https://gitlab.gnome.org/GNOME/libxml2/-/commit/2554a24

All versions of libml2 prior to v2.9.14 are affected.

Applications 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.

References

Advisory Timeline

  • First published May 18, 2022 (1653 days ago).
  • Last revised August 27, 2026 — 1561 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Bundler
Update nokogiri to 1.13.5 or later
gem install nokogiri -v 1.13.5

After upgrading, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (1)

Affects 1 ecosystem: RubyGems (1).

PackageFixed In
nokogiri RubyGems · Affected: 1.0.0, 1.0.1, 1.0.2, 1.0.3 (+140 more)1.13.5

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 8.6 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
High

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:H

Frequently Asked Questions

What is CVE-2022-50999?
Integer Overflow or Wraparound in libxml2 affects Nokogiri. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 8.6/10).
How do I check if my project is affected by CVE-2022-50999?
CVE-2022-50999 affects nokogiri. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2022-50999 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
8.6

Significant impact if exploited, or exploitable with modest effort.

Also Known As

GHSA-cgx6-hpwq-fhv5

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my Gemfile.lock