CVE-2026-126064: Nokogiri: Use-After-Free in Nokogiri when replacing an attribute value
Published 2026-11-10 · Updated 2026-11-10 · Also known as GHSA-3w22-6jfg-527w
Summary
Nokogiri has a Use-After-Free vulnerability in its CRuby native extension when replacing an attribute value, which can cause a segfault. Ruby developers and engineering teams using vulnerable versions of Nokogiri should upgrade immediately.
Who is affected
This flaw affects applications using RubyGems nokogiri before version 1.19.5, specifically when running on CRuby. Reaching the vulnerability requires an unusual API-usage pattern where the application directly accesses an attribute's child nodes before replacing that same attribute's value via `Node#[]=` or `Node#lang=`. Successful exploitation can result in an invalid read and a possible segmentation fault.
Exploitability
The vulnerability has a low CVSS 4.0 base score with a local attack vector, high attack complexity, and low privileges required, meaning local access with specific conditions is needed. The EPSS score is very low at 0.002, and it is not currently listed in the CISA Known Exploited Vulnerabilities catalog.
Remediation
- Upgrade the Nokogiri gem to version 1.19.5 or later.
- As a workaround, avoid accessing attribute child nodes directly via `Attr#children` or similar methods before replacing the same attribute's value.
How to check your project
- Check the project's Gemfile or Gemfile.lock to verify if the 'nokogiri' gem version is below 1.19.5.
Automated analysis of the published advisory data, generated 2026-11-19. Not human-reviewed; verify against the official advisory. How this works.
Affected packages
| Ecosystem | Package | Affected versions | Fixed in | Upgrade |
|---|---|---|---|---|
| RubyGems | nokogiri |
>= 0, < 1.19.5 | 1.19.5 | bundle update nokogiri |
CVSS 4.0 vector
CVSS:4.0/AV:L/AC:H/AT:P/PR:L/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
| Attack vector | Local |
|---|---|
| Attack complexity | High |
| Attack requirements | Present |
| Privileges required | Low |
| User interaction | None |
| Confidentiality (vulnerable system) | None |
| Integrity (vulnerable system) | None |
| Availability (vulnerable system) | Low |
| Confidentiality (subsequent systems) | None |
| Integrity (subsequent systems) | None |
| Availability (subsequent systems) | None |
Base score is not computed for CVSS 4.0 vectors; severity is taken from the advisory.
FAQ
What causes the Use-After-Free condition in Nokogiri?
It occurs when replacing the value of an existing XML attribute via `Node#[]=` or `Node#lang=` after Ruby code has already accessed the attribute's child nodes, leaving a Ruby wrapper pointing to freed native memory.
Are JRuby users affected by this vulnerability?
No, JRuby is not affected by this vulnerability.
What is the fixed version for this issue?
Nokogiri version 1.19.5 fixes the issue by preserving all already-wrapped attribute child nodes before replacing the attribute value.
Original advisory description
References
- WEB https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-3w22-6jfg-527w
- WEB https://github.com/sparklemotion/nokogiri/pull/3752
- WEB https://github.com/sparklemotion/nokogiri/commit/b15b518db9fd15fd6b046f73d1439c282e5cc425
- WEB https://github.com/sparklemotion/nokogiri/commit/feaed3c8c9bd9d81d064d4ca09b16044cd705d6f
- WEB https://github.com/rubysec/ruby-advisory-db/blob/master/gems/nokogiri/GHSA-3w22-6jfg-527w.yml
- PACKAGE https://github.com/sparklemotion/nokogiri
- WEB https://github.com/sparklemotion/nokogiri/releases/tag/v1.19.5
Source records: GHSA-3w22-6jfg-527w (OSV.dev) · EPSS by FIRST, 2026-11-26.