{"id":"CVE-2026-57437","aliases":["CVE-2026-57437","GHSA-p67v-3w7g-wjg7"],"related":[],"kind":"vulnerability","state":"published","title":"Nokogiri: Possible Use-After-Free when directly using `NokogirI::XML::XPathContext` beyond document lifetime","summary":"Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, Nokogiri::XML::XPathContext did not keep its source document alive for garbage collection. If an XPathContext outlived its document and the document was collected, evaluating an XPath expression could read invalid memory and potentially segfault. This is only reachable when application code constructs an XPathContext directly and lets the document become unreachable while continuing to use the context. The normal Document#xpath, #css, and related search methods are not affected, and it is not triggerable by malicious document input. This vulnerability is fixed in 1.19.4.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, Nokogiri::XML::XPathContext did not keep its source document alive for garbage collection. If an XPathContext outlived its document and the document was collected, evaluating an XPath expression could read invalid memory and potentially segfault. This is only reachable when application code constructs an XPathContext directly and lets the document become unreachable while continuing to use the context. The normal Document#xpath, #css, and related search methods are not affected, and it is not triggerable by malicious document input. This vulnerability is fixed in 1.19.4.","source":"cvelist"},{"lang":"en","text":"### Summary\n\n`Nokogiri::XML::XPathContext` did not keep its source document alive for garbage collection. If an `XPathContext` outlived its document and the document was collected, evaluating an XPath expression could read invalid memory and potentially segfault.\n\nThis is only reachable when application code constructs an `XPathContext` directly and lets the document become unreachable while continuing to use the context. The normal `Document#xpath`, `#css`, and related search methods are not affected, and it is not triggerable by malicious document input.\n\nNokogiri 1.19.4 makes `XPathContext` keep its source document alive for as long as the context exists.\n\nOnly the CRuby implementation is affected. JRuby is not affected.\n\n### Severity\n\nThe Nokogiri maintainers have evaluated this as low severity. Reaching it requires an unusual API-usage pattern that does not arise during normal use. The application must construct an `XML::XPathContext` directly and continue using it after allowing its source document to be garbage-collected. Nokogiri 1.19.4 makes this pattern safe with no change to the public API. The context now keeps its source document alive for as long as it exists.\n\n### Mitigation\n\nUpgrade to Nokogiri 1.19.4 or later.\n\nAs a workaround, ensure the source document remains referenced for as long as any `XPathContext` created from it is in use. The standard `Document#xpath`, `#css`, and related search methods already do this and are unaffected.\n\n### Credit\n\nThis issue was responsibly reported by Zheng Yu from depthfirst.com.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Nokogiri es una biblioteca XML y HTML de código abierto para el lenguaje de programación Ruby. Antes de la 1.19.4, Nokogiri::XML::XPathContext no mantenía su documento fuente vivo para la recolección de basura. Si un XPathContext sobrevivía a su documento y el documento era recolectado, evaluar una expresión XPath podría leer memoria inválida y potencialmente causar un segfault. Esto solo es alcanzable cuando el código de la aplicación construye un XPathContext directamente y permite que el documento se vuelva inalcanzable mientras se continúa usando el contexto. Los métodos de búsqueda normales Document#xpath, #css y relacionados no se ven afectados, y no es activable por entrada de documento malicioso. Esta vulnerabilidad está corregida en la 1.19.4.","source":"nvd"}],"published":"2026-06-19T16:37:13.000Z","modified":"2026-10-25T23:10:00.167Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U/U:Clear","score":1.7,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U/U:Clear","score":1.7,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U/U:Clear","rating":"LOW"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"}],"cwes":["CWE-416"],"affected":[{"ranges":[{"version":"< 1.19.4","status":"affected"}],"vendor":"sparklemotion","product":"nokogiri","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.19.4"}],"ecosystem":"RubyGems","package":"nokogiri","purl":"pkg:gem/nokogiri","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.19.4"}],"vendor":"nokogiri","product":"nokogiri","cpe":"cpe:2.3:a:nokogiri:nokogiri:*:*:*:*:*:ruby:*:*","source":"nvd"}],"references":[{"url":"https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-p67v-3w7g-wjg7","tags":["mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sparklemotion/nokogiri","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-06-25T14:59:55.399Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-57437","url":"https://www.cve.org/CVERecord?id=CVE-2026-57437","licence":"CVE Terms of Use","modified":"2026-06-25T15:00:01.455Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-p67v-3w7g-wjg7","url":"https://github.com/advisories/GHSA-p67v-3w7g-wjg7","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:09.256Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-57437","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-57437","licence":"Public domain","modified":"2026-10-25T23:10:00.167Z"}],"updatedAt":"2026-11-25T22:59:26.372Z","epss":{"score":0.00321,"percentile":0.27129,"date":"2026-12-01T12:00:22.000Z"}}