Nokogiri: Possible Use-After-Free when setting an attribute value via `Nokogiri::XML::Node#[]=` or `#lang=`
- State
- Published
- Severity
- 2.0 Low
- Published
- Nov 10, 2026
- Updated
- Nov 10, 2026
- Reserved
- Nov 10, 2026
Description
Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.5, the CRuby native extension can leave Ruby wrappers pointing to freed memory when Nokogiri::XML::Node#[]= or Nokogiri::XML::Node#lang= replaces an existing attribute value after code has accessed the attribute's child nodes. Replacing the value frees native child nodes while their wrappers remain reachable, and later use of those wrappers can cause an invalid read or process segfault. JRuby is not affected. This issue is fixed in version 1.19.5.
| Product | Versions |
|---|---|
| nokogiri sparklemotion | < 1.19.5 Affected |
| CVSS | Score | How It's Reached | Source |
|---|---|---|---|
| 4.0 | 2.0 Low | GitHub_M |
Weaknesses
- CWE-416 Use After Free
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/sparklemotion/nokogiri/releases/tag/v1.19.5
Every record here comes from the CVE Program's CVE List. © 1999-2026 The MITRE Corporation. CVE is a registered trademark of The MITRE Corporation. The records are reproduced under the CVE Program terms of use.