CVE-2026-126064: Nokogiri: Use-After-Free in Nokogiri when replacing an attribute value
Summary 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.
Published Nov 10, 2026
Affected packages
nokogiri
- Ecosystem
- RubyGems
- Affected
- < 1.19.5
- Fixed in
- 1.19.5
- Check
bundle info nokogiri
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
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.
Severity
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.
Mitigation
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.
Credit
This issue was responsibly reported by zx (@manus-pi).
Credited to manus-pi.
References
- https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-3w22-6jfg-527w
- https://github.com/sparklemotion/nokogiri/pull/3752
- https://github.com/sparklemotion/nokogiri/commit/b15b518db9fd15fd6b046f73d1439c282e5cc425
- https://github.com/sparklemotion/nokogiri/commit/feaed3c8c9bd9d81d064d4ca09b16044cd705d6f
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/nokogiri/GHSA-3w22-6jfg-527w.yml
- https://github.com/sparklemotion/nokogiri/releases/tag/v1.19.5
- https://github.com/advisories/GHSA-3w22-6jfg-527w
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More RubyGems vulnerabilities
All RubyGems entriesCVE-2026-126062
JRuby: NONET is bypassed for external DTDs and entities when the systemId uses a short-form IPv4 host
low3.7Nov 10, 2026CVE-2026-126063
Nokogiri: Mutation XSS through `noscript` content in Nokogiri's HTML5 serializer
low2.3Nov 10, 2026GHSA-5prr-v3j2-97mh
Nokogiri: Possible Out-of-Bounds Read in `Nokogiri::XML::NodeSet#[]`
medium6.3Jun 19, 2026GHSA-5v8h-3h3q-446p
Nokogiri: Possible Use-After-Free when `Nokogiri::XML::Document#encoding=` raises an exception
low1.7Jun 19, 2026GHSA-8678-w3jw-xfc2
Nokogiri: XML::Schema on JRuby allows network requests when NONET is set, bypassing CVE-2020-26247
low2.6Jun 19, 2026GHSA-9cv2-cfxc-v4v2
Nokogiri: Null Pointer Dereference calling methods on uninitialized wrapper classes
low1.7Jun 19, 2026
