# CVE-2026-57435: Nokogiri use-after-free in XML attribute value replacement

Source: https://junglewise.ai/threats/cve-2026-57435-nokogiri-use-after-free-in-xml-attribute-value-replacement  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-06-25. Updated: 2026-06-25  
License: CC BY 4.0 with a link back

CVE-2026-57435 · Severity: medium · CVSS 4 · Published 2026-06-25

Nokogiri is a widely used Ruby library for processing XML and HTML data. A technical flaw in how the library handles memory when updating document attributes could lead to application crashes (segmentation faults). While this issue is unlikely to occur during standard use, it could impact the stability of applications that perform complex manipulations of XML data.

Technologies: [nokogiri (RubyGems)](https://junglewise.ai/threats/technologies/nokogiri). Vendors: [RubyGems](https://junglewise.ai/threats/vendors/rubygems).

## Quick answers

**Is CVE-2026-57435 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-57435 being exploited in the wild.

**How severe is CVE-2026-57435?** Medium severity, with a CVSS score of 4, published 25 June 2026.

**Which products and versions are affected?** nokogiri (RubyGems) ECOSYSTEM:introduced=0,fixed=1.19.4.

**Is there a fix for CVE-2026-57435?** Yes. nokogiri (RubyGems): upgrade to 1.19.4 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-57435 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-57435?** Check whether you run nokogiri (RubyGems) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- nokogiri (RubyGems): upgrade to 1.19.4 or later

  ```sh
  bundle update nokogiri
  ```


## Technical details

A use-after-free (CWE-416) and expired pointer dereference (CWE-825) vulnerability exists in Nokogiri's CRuby native extension. When a Ruby wrapper for an attribute's child node is accessed and subsequently the attribute's value is replaced using `Nokogiri::XML::Attr#value=` or `#content=`, the underlying native memory for the child node is freed while the Ruby wrapper remains reachable. Subsequent access or Ruby Garbage Collection (GC) marking can dereference this invalid pointer, leading to an invalid read and a segmentation fault. This issue is specific to the CRuby implementation; JRuby is not affected. The vulnerability is addressed in version 1.19.4 by ensuring already-wrapped child nodes are preserved during value replacement.

## Affected products

- sparklemotion nokogiri < 1.19.4

## Identifiers

- CVE-2026-57435
- GHSA-phwj-rprq-35pp

## Timeline

- 2026-06-18: advisory: GitHub advisory published by maintainers
- 2026-06-25: disclosed: CVE published to NVD

## References

- [https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-phwj-rprq-35pp](https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-phwj-rprq-35pp)

## Related threats

- [Nokogiri use-after-free in attribute replacement](https://junglewise.ai/threats/cve-2026-126064-nokogiri-is-an-open-source-xml-and-html-library-for-the-ruby)
- [Nokogiri HTML5 serializer mutation XSS via noscript and attributes](https://junglewise.ai/threats/cve-2026-126063-nokogiri-is-an-open-source-xml-and-html-library-for-the-ruby)
- [JRuby: NONET is bypassed for external DTDs and entities when the systemId uses a short-form IPv4 host](https://junglewise.ai/threats/cve-2026-126062-nokogiri-is-an-open-source-xml-and-html-library-for-the-ruby)
- [Nokogiri unchecked return value in canonicalize method](https://junglewise.ai/threats/nokogiri-unchecked-return-value-in-canonicalize-method-3863de91)
- [Nokogiri XSLT transform memory leak](https://junglewise.ai/threats/nokogiri-xslt-transform-memory-leak-0441ddf7)
