Nokogiri's CRuby native extension could leave a Ruby wrapper pointing to freed memory when replacing the value of an existing XML attribute via Nokogiri::XML::Node#[]= or Nokogiri::XML::Node#lang=. If Ruby code had already accessed the attribute's child nodes, replacing the value could free those native child nodes while their wrappers remained reachable. Using one of those child nodes afterwards could cause an invalid read and a possible segfault.
This is the same class of issue as GHSA-phwj-rprq-35pp, which was fixed for Attr#value= in Nokogiri 1.19.4.
Nokogiri 1.19.5 preserves all already-wrapped attribute child nodes before replacing the attribute value.
JRuby is not affected.
The 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 nodes and then replace that same attribute's value via Node#[]= or Node#lang=. Nokogiri 1.19.5 makes this pattern safe with no change to the public API.
Upgrade to Nokogiri 1.19.5 or later.
As a workaround, avoid accessing attribute child nodes directly via Attr#children or similar before replacing the same attribute's value.
This issue was responsibly reported by zx (@manus-pi).
{
"cwe_ids": [
"CWE-416"
],
"github_reviewed": true,
"github_reviewed_at": "2026-11-10T20:51:19Z",
"nvd_published_at": null,
"severity": "LOW"
}