CVE-2022-24836: Nokogiri Nokogiri Inefficient Regular Expression Complexity Vulnerability

HIGH
Advisory Identifier: GHSA-crjr-9rc5-ghw8
CVSS 7.5
CWE-400 CWE-1333
Published
Advisory Summary

CVE-2022-24836 is a HIGH (CVSS 7.5) nokogiri inefficient regular expression complexity vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Nokogiri libraries in the RubyGems ecosystem. The issue involves nokogiri inefficient regular expression complexity. Remediation is available by upgrading affected packages to version 1.13.4.

CVE-2022-24836 at a Glance

CVE Identifier CVE-2022-24836
GHSA Identifier GHSA-crjr-9rc5-ghw8
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Nokogiri
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 7.5

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:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2022-24836

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.

nokogiri fixed: 1.13.4
Upgrade nokogiri to 1.13.4
Verify Direct and Transitive Dependencies

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 CVE-2022-24836, 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.4), 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-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. 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

## Summary Nokogiri `< v1.13.4` contains an inefficient regular expression that is susceptible to excessive backtracking when attempting to detect encoding in HTML documents. ## Mitigation Upgrade to Nokogiri `>= 1.13.4`. ## Severity The Nokogiri maintainers have evaluated this as [**High Severity** 7.5 (CVSS3.1)](https://www.first.org/cvss/calculator/3.1#CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H). ## References [CWE-1333](https://cwe.mitre.org/data/definitions/1333.html) Inefficient Regular Expression Complexity ## Credit This vulnerability was reported by HackerOne user ooooooo_q (ななおく).

CVE-2022-24836 Affected Nokogiri Versions

1 component(s)
Fixed Versions:
1.13.4
Product / Package Ecosystem Affected Versions Fixed Version
nokogiri
RubyGems
< 1.13.4
1.13.4

References

GitHub Advisory / Wiki ADVISORY
https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-crjr-9rc5-ghw8
NVD — CVE-2022-24836 NVD
https://nvd.nist.gov/vuln/detail/CVE-2022-24836
Security Fix Commit FIX COMMIT
https://github.com/sparklemotion/nokogiri/commit/e444525ef1634b675cd1cf52d39f4320ef0aecfd
Nokogiri Source Repository REPOSITORY
https://github.com/rubysec/ruby-advisory-db/blob/master/gems/nokogiri/CVE-2022-24836.yml
Nokogiri Source Repository REPOSITORY
https://github.com/sparklemotion/nokogiri
Nokogiri Release RELEASE
https://github.com/sparklemotion/nokogiri/releases/tag/v1.13.4
Nokogiri Security Information SECURITY
https://groups.google.com/g/ruby-security-ann/c/vX7qSjsvWis/m/TJWN4oOKBwAJ?utm_medium=email&utm_source=footer
lists.debian.org/debian-lts-announce... WEB
https://lists.debian.org/debian-lts-announce/2022/05/msg00013.html
lists.debian.org/debian-lts-announce... WEB
https://lists.debian.org/debian-lts-announce/2022/10/msg00018.html
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/6DHCOWMA5PQTIQIMDENA7R2Y5BDYAIYM
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/OUPLBUZVM4WPFSXBEP2JS3R6LMKRTLFC
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XMDCWRQXJQ3TFSETPCEFMQ6RR6ME5UA3
Nokogiri Security Information SECURITY
https://security.gentoo.org/glsa/202208-29
support.apple.com/kb/ht213532 WEB
https://support.apple.com/kb/HT213532
seclists.org/fulldisclosure/2022... WEB
http://seclists.org/fulldisclosure/2022/Dec/23

Frequently Asked Questions

What is CVE-2022-24836?
CVE-2022-24836 is a security vulnerability in Nokogiri involving Nokogiri Inefficient Regular Expression Complexity under CWE-400: Uncontrolled Resource Consumption.
Which Nokogiri versions are affected?
Affected versions include releases prior to 1.13.4 across affected packages: nokogiri.
What version fixes CVE-2022-24836?
Upgrading to 1.13.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nokogiri affected?
Yes, nokogiri is affected in releases prior to 1.13.4. Upgrade your dependency to 1.13.4 or later.
What is the CVSS score of CVE-2022-24836?
CVE-2022-24836 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2022-24836?
CVE-2022-24836 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check RubyGems dependencies for CVE-2022-24836?
Run the dependency tree command: 'inspect dependencies for nokogiri'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-crjr-9rc5-ghw8",
  "modified" : "2023-07-06T16:02:37Z",
  "published" : "2022-04-11T21:18:06Z",
  "aliases" : [ "CVE-2022-24836" ],
  "summary" : "Nokogiri Inefficient Regular Expression Complexity",
  "details" : "## Summary\n\nNokogiri `< v1.13.4` contains an inefficient regular expression that is susceptible to excessive backtracking when attempting to detect encoding in HTML documents.\n\n## Mitigation\n\nUpgrade to Nokogiri `>= 1.13.4`.\n\n\n## Severity\n\nThe Nokogiri maintainers have evaluated this as [**High Severity** 7.5 (CVSS3.1)](https://www.first.org/cvss/calculator/3.1#CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).\n\n\n## References\n\n[CWE-1333](https://cwe.mitre.org/data/definitions/1333.html) Inefficient Regular Expression Complexity\n\n\n## Credit\n\nThis vulnerability was reported by HackerOne user ooooooo_q (ななおく).\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "nokogiri"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.13.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-crjr-9rc5-ghw8"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24836"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/nokogiri/commit/e444525ef1634b675cd1cf52d39f4320ef0aecfd"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/nokogiri/CVE-2022-24836.yml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sparklemotion/nokogiri"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/nokogiri/releases/tag/v1.13.4"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/g/ruby-security-ann/c/vX7qSjsvWis/m/TJWN4oOKBwAJ?utm_medium=email&utm_source=footer"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2022/05/msg00013.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2022/10/msg00018.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/6DHCOWMA5PQTIQIMDENA7R2Y5BDYAIYM"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/OUPLBUZVM4WPFSXBEP2JS3R6LMKRTLFC"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XMDCWRQXJQ3TFSETPCEFMQ6RR6ME5UA3"
  }, {
    "type" : "WEB",
    "url" : "https://security.gentoo.org/glsa/202208-29"
  }, {
    "type" : "WEB",
    "url" : "https://support.apple.com/kb/HT213532"
  }, {
    "type" : "WEB",
    "url" : "http://seclists.org/fulldisclosure/2022/Dec/23"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333", "CWE-400" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-04-11T21:18:06Z",
    "nvd_published_at" : "2022-04-11T22:15:00Z"
  }
}