CVE-2019-18197: Nokogiri Remote Code Execution Vulnerability
HIGHCVE-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
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).
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.
Upgrade nokogiri to 1.10.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 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
CVE-2019-18197 Affected Nokogiri Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nokogiri
|
RubyGems |
< 1.10.5
|
1.10.5
|
References
Frequently Asked Questions
What is CVE-2019-18197?
Which Nokogiri versions are affected?
What version fixes CVE-2019-18197?
Is nokogiri affected?
What is the CVSS score of CVE-2019-18197?
What CWE is associated with CVE-2019-18197?
How can I check RubyGems dependencies for CVE-2019-18197?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}