{"id":"CVE-2026-57436","aliases":["CVE-2026-57436","GHSA-wjv4-x9w8-wm3h"],"related":[],"kind":"vulnerability","state":"published","title":"Nokogiri: Possible Use-After-Free when setting `Document#root=` to an invalid node type","summary":"Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, Nokogiri::XML::Document#root= validated only that the new root was a Nokogiri::XML::Node, allowing a DTD node to be set as the document root. The result is a heap use-after-free during garbage collection or finalization, leading to an invalid memory read or potentially a segfault. 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::Document#root= validated only that the new root was a Nokogiri::XML::Node, allowing a DTD node to be set as the document root. The result is a heap use-after-free during garbage collection or finalization, leading to an invalid memory read or potentially a segfault. This vulnerability is fixed in 1.19.4.","source":"cvelist"},{"lang":"en","text":"### Summary\n\n`Nokogiri::XML::Document#root=` validated only that the new root was a `Nokogiri::XML::Node`, allowing a DTD node to be set as the document root. The result is a heap use-after-free during garbage collection or finalization, leading to an invalid memory read or potentially a segfault.\n\nNokogiri 1.19.4 restricts `Document#root=` to element nodes, raising `TypeError` for any other node type.\n\nThis memory-safety issue affects only the CRuby implementation (libxml2). The JRuby implementation was not affected; the same input validation was added there for behavioral parity.\n\n### Severity\n\nThe Nokogiri maintainers have evaluated this as low severity. This is only triggered by a programming error. It requires application code to assign a non-element node such as a DTD as the document root via `Document#root=`. Nokogiri 1.19.4 now raises `TypeError` instead of allowing a use-after-free. It cannot be triggered by untrusted input or through normal use of the public API.\n\n### Mitigation\n\nUpgrade to Nokogiri 1.19.4 or later.\n\nAs a workaround, applications that cannot upgrade should avoid assigning a DTD (or any non-element node) via `Document#root=`.\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 versión 1.19.4, Nokogiri::XML::Document#root= validaba únicamente que la nueva raíz fuera un Nokogiri::XML::Node, permitiendo que un nodo DTD se estableciera como la raíz del documento. El resultado es un uso después de liberación en el heap durante la recolección de basura o la finalización, lo que lleva a una lectura de memoria no válida o potencialmente a un segfault. Esta vulnerabilidad se corrige en la versión 1.19.4.","source":"nvd"}],"published":"2026-06-19T16:36:59.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","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","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","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-wjv4-x9w8-wm3h","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":"yes","technicalImpact":"total","date":"2026-06-25T23:26:42.649Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-57436","url":"https://www.cve.org/CVERecord?id=CVE-2026-57436","licence":"CVE Terms of Use","modified":"2026-06-25T23:27:34.410Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-wjv4-x9w8-wm3h","url":"https://github.com/advisories/GHSA-wjv4-x9w8-wm3h","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:50.907Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-57436","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-57436","licence":"Public domain","modified":"2026-10-25T23:10:00.167Z"}],"updatedAt":"2026-11-25T22:59:26.371Z","epss":{"score":0.00321,"percentile":0.27129,"date":"2026-12-01T12:00:22.000Z"}}