LOW · CVSS 4.0 EPSS 0.1% · 2th percentile CWE-416

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

How to check your project

Automated analysis of the published advisory data, generated 2026-11-19. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
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 vectorLocal
Attack complexityHigh
Attack requirementsPresent
Privileges requiredLow
User interactionNone
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
### 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](https://github.com/sparklemotion/nokogiri/security/advisories/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).

References

Source records: GHSA-3w22-6jfg-527w (OSV.dev) · EPSS by FIRST, 2026-11-26.