{"id":"CVE-2026-57435","aliases":["CVE-2026-57435","GHSA-phwj-rprq-35pp"],"related":[],"kind":"vulnerability","state":"published","title":"Nokogiri: Possible Use-After-Free when setting an attribute value via `Nokogiri::XML::Attr#value=` or `#content=`","summary":"Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, Nokogiri’s CRuby native extension could leave a Ruby wrapper pointing to freed memory when replacing the value of an XML attribute. If Ruby code had already accessed an attribute child node, Nokogiri::XML::Attr#value= could free the underlying native child node while the wrapper remained reachable through the document node cache. A later use of the freed child node or a Ruby GC mark could dereference an invalid pointer, causing an invalid read and a possible 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’s CRuby native extension could leave a Ruby wrapper pointing to freed memory when replacing the value of an XML attribute. If Ruby code had already accessed an attribute child node, Nokogiri::XML::Attr#value= could free the underlying native child node while the wrapper remained reachable through the document node cache. A later use of the freed child node or a Ruby GC mark could dereference an invalid pointer, causing an invalid read and a possible segfault. This vulnerability is fixed in 1.19.4.","source":"cvelist"},{"lang":"en","text":"### Summary\n\nNokogiri’s CRuby native extension could leave a Ruby wrapper pointing to freed memory when replacing the value of an XML attribute. If Ruby code had already accessed an attribute child node, `Nokogiri::XML::Attr#value=` could free the underlying native child node while the wrapper remained reachable through the document node cache. A later use of the freed child node or a Ruby GC mark could dereference an invalid pointer, causing an invalid read and a possible segfault.\n\nNokogiri 1.19.4 preserves any already-wrapped attribute child nodes before replacing the attribute value.\n\nJRuby 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 directly access an attribute's child node and then replace that same attribute's value via `Attr#value=` or `#content=`. Nokogiri 1.19.4 makes this pattern safe with no change to the public API. Already-wrapped attribute child nodes are preserved before the value is replaced.\n\n### Mitigation\n\nUpgrade to Nokogiri 1.19.4 or later.\n\nAs a workaround, avoid accessing attribute child nodes directly via `Attr#child` or similar before mutating the same attribute’s value.\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 de código abierto de XML y HTML para el lenguaje de programación Ruby. Antes de 1.19.4, la extensión nativa CRuby de Nokogiri podría dejar un wrapper de Ruby apuntando a memoria liberada al reemplazar el valor de un atributo XML. Si el código Ruby ya había accedido a un nodo hijo de atributo, Nokogiri::XML::Attr#value= podría liberar el nodo hijo nativo subyacente mientras el wrapper permanecía accesible a través de la caché de nodos del documento. Un uso posterior del nodo hijo liberado o una marca de GC de Ruby podría desreferenciar un puntero inválido, causando una lectura inválida y un posible segfault. Esta vulnerabilidad se corrige en 1.19.4.","source":"nvd"}],"published":"2026-06-19T16:37:46.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:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-416","CWE-825"],"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-phwj-rprq-35pp","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:53:12.909Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-57435","url":"https://www.cve.org/CVERecord?id=CVE-2026-57435","licence":"CVE Terms of Use","modified":"2026-06-25T14:53:19.607Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-phwj-rprq-35pp","url":"https://github.com/advisories/GHSA-phwj-rprq-35pp","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:09.239Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-57435","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-57435","licence":"Public domain","modified":"2026-10-25T23:10:00.167Z"}],"updatedAt":"2026-11-25T22:59:26.371Z","epss":{"score":0.00368,"percentile":0.22785,"date":"2026-11-30T12:00:22.000Z"}}