CVE-2019-18197: Nokogiri Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-242x-7cm6-4w8j
CVSS 7.5
CWE-416 CWE-908
Published
Advisory Summary

CVE-2019-18197 is a HIGH (CVSS 7.5) remote code execution vulnerability (CWE-416: Use After Free) affecting Nokogiri libraries in the RubyGems ecosystem. The issue involves nokogiri affected by libxslt use of uninitialized resource/use after free vulnerability. Remediation is available by upgrading affected packages to version 1.10.5.

CVE-2019-18197 at a Glance

CVE Identifier CVE-2019-18197
GHSA Identifier GHSA-242x-7cm6-4w8j
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-416: Use After Free
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:H/PR:N/UI:R/S:U/C:H/I:H/A:H).

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

How to Fix CVE-2019-18197

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.10.5
Upgrade nokogiri to 1.10.5
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-2019-18197, 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.10.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-416: Use After Free, where the product reuses or references memory after it has been freed. at some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer. 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

In xsltCopyText in transform.c in libxslt 1.1.33, a pointer variable isn't reset under certain circumstances. If the relevant memory area happened to be freed and reused in a certain way, a bounds check could fail and memory outside a buffer could be written to, or uninitialized data could be disclosed. Nokogiri prior to version 1.10.5 contains a vulnerable version of libxslt. Nokogiri version 1.10.5 upgrades the dependency to libxslt 1.1.34, which contains a patch for this issue.

CVE-2019-18197 Affected Nokogiri Versions

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

References

NVD — CVE-2019-18197 NVD
https://nvd.nist.gov/vuln/detail/CVE-2019-18197
Nokogiri Source Repository REPOSITORY
https://github.com/sparklemotion/nokogiri/issues/1943
access.redhat.com/errata/rhsa-2020:05... WEB
https://access.redhat.com/errata/RHSA-2020:0514
bugs.chromium.org/p/oss-fuzz/issues/d... WEB
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15746
bugs.chromium.org/p/oss-fuzz/issues/d... WEB
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15768
bugs.chromium.org/p/oss-fuzz/issues/d... WEB
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15914
Nokogiri Source Repository REPOSITORY
https://github.com/rubysec/ruby-advisory-db/blob/master/gems/nokogiri/CVE-2019-18197.yml
Nokogiri Source Repository REPOSITORY
https://github.com/sparklemotion/nokogiri
Nokogiri Source Repository REPOSITORY
https://github.com/sparklemotion/nokogiri/blob/01ab95f3e37429ed8d3b380a8d2f73902eb325d9/CHANGELOG.md?plain=1#L934
gitlab.gnome.org/gnome/libxslt/commi... WEB
https://gitlab.gnome.org/GNOME/libxslt/commit/2232473733b7313d67de8836ea3b29eec6e8e285
lists.debian.org/debian-lts-announce... WEB
https://lists.debian.org/debian-lts-announce/2019/10/msg00037.html
Nokogiri Security Information SECURITY
https://security.netapp.com/advisory/ntap-20191031-0004
Nokogiri Security Information SECURITY
https://security.netapp.com/advisory/ntap-20200416-0004
usn.ubuntu.com/4164-1 WEB
https://usn.ubuntu.com/4164-1
Nokogiri Security Information SECURITY
https://www.oracle.com/security-alerts/cpuapr2020.html
Nokogiri Security Information SECURITY
http://lists.opensuse.org/opensuse-security-announce/2020-02/msg00010.html
Nokogiri Security Information SECURITY
http://lists.opensuse.org/opensuse-security-announce/2020-02/msg00015.html
Nokogiri Security Information SECURITY
http://lists.opensuse.org/opensuse-security-announce/2020-02/msg00025.html
Nokogiri Security Information SECURITY
http://lists.opensuse.org/opensuse-security-announce/2020-05/msg00062.html
Nokogiri Security Information SECURITY
http://www.openwall.com/lists/oss-security/2019/11/17/2

Frequently Asked Questions

What is CVE-2019-18197?
CVE-2019-18197 is a security vulnerability in Nokogiri involving Nokogiri affected by libxslt Use of Uninitialized Resource/Use After Free vulnerability under CWE-416: Use After Free.
Which Nokogiri versions are affected?
Affected versions include releases prior to 1.10.5 across affected packages: nokogiri.
What version fixes CVE-2019-18197?
Upgrading to 1.10.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nokogiri affected?
Yes, nokogiri is affected in releases prior to 1.10.5. Upgrade your dependency to 1.10.5 or later.
What is the CVSS score of CVE-2019-18197?
CVE-2019-18197 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2019-18197?
CVE-2019-18197 is classified under CWE-416: Use After Free (The product reuses or references memory after it has been freed. At some point afterward, the memory may be allocated again and saved in another pointer, while the original pointer references a location somewhere within the new allocation. Any operations using the original pointer are no longer valid because the memory "belongs" to the code that operates on the new pointer.).
How can I check RubyGems dependencies for CVE-2019-18197?
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-242x-7cm6-4w8j",
  "modified" : "2026-06-09T10:22:03Z",
  "published" : "2022-05-24T16:59:28Z",
  "aliases" : [ "CVE-2019-18197" ],
  "summary" : "Nokogiri affected by libxslt Use of Uninitialized Resource/Use After Free vulnerability",
  "details" : "In xsltCopyText in transform.c in libxslt 1.1.33, a pointer variable isn't reset under certain circumstances. If the relevant memory area happened to be freed and reused in a certain way, a bounds check could fail and memory outside a buffer could be written to, or uninitialized data could be disclosed.\n\nNokogiri prior to version 1.10.5 contains a vulnerable version of libxslt. Nokogiri version 1.10.5 upgrades the dependency to libxslt 1.1.34, which contains a patch for this issue.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "nokogiri"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.10.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2019-18197"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/nokogiri/issues/1943"
  }, {
    "type" : "WEB",
    "url" : "https://access.redhat.com/errata/RHSA-2020:0514"
  }, {
    "type" : "WEB",
    "url" : "https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15746"
  }, {
    "type" : "WEB",
    "url" : "https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15768"
  }, {
    "type" : "WEB",
    "url" : "https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15914"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/nokogiri/CVE-2019-18197.yml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/sparklemotion/nokogiri"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sparklemotion/nokogiri/blob/01ab95f3e37429ed8d3b380a8d2f73902eb325d9/CHANGELOG.md?plain=1#L934"
  }, {
    "type" : "WEB",
    "url" : "https://gitlab.gnome.org/GNOME/libxslt/commit/2232473733b7313d67de8836ea3b29eec6e8e285"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2019/10/msg00037.html"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20191031-0004"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20200416-0004"
  }, {
    "type" : "WEB",
    "url" : "https://usn.ubuntu.com/4164-1"
  }, {
    "type" : "WEB",
    "url" : "https://www.oracle.com/security-alerts/cpuapr2020.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2020-02/msg00010.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2020-02/msg00015.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2020-02/msg00025.html"
  }, {
    "type" : "WEB",
    "url" : "http://lists.opensuse.org/opensuse-security-announce/2020-05/msg00062.html"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2019/11/17/2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-416", "CWE-908" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-07-07T21:30:20Z",
    "nvd_published_at" : "2019-10-18T21:15:00Z"
  }
}