CVE-2026-57236: CWE-416: Use After Free in sparklemotion nokogiri
Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, calling Document#encoding= with an invalid encoding (e.g., a non-string, or a string containing a null byte) raises an exception, but only after freeing the document's current encoding string without replacing it. The document is left referencing freed memory, so the next call to Document#encoding reads invalid memory, which can cause a segfault or leak freed bytes into a Ruby String. Affects the CRuby (libxml2) implementation only; JRuby is not affected. This vulnerability is fixed in 1.19.4.
AI Analysis
Technical Summary
CVE-2026-57236 is a use-after-free vulnerability in the Nokogiri XML and HTML library for Ruby. When Document#encoding= is called with an invalid encoding (such as a non-string or a string containing a null byte) in versions prior to 1.19.4, the current encoding string is freed without being replaced. This leaves the document referencing freed memory, causing subsequent calls to Document#encoding to read invalid memory. This can result in a segmentation fault or leaking freed bytes into a Ruby String. The vulnerability affects only the CRuby implementation using libxml2 and does not impact JRuby. The issue is resolved in Nokogiri version 1.19.4.
Potential Impact
The vulnerability can cause application crashes (segmentation faults) or memory leakage due to use-after-free conditions when handling invalid encoding inputs. This may affect application stability but does not indicate direct remote code execution or data corruption beyond memory leakage. No known exploits are reported in the wild.
Mitigation Recommendations
Upgrade Nokogiri to version 1.19.4 or later, where this use-after-free vulnerability is fixed. No other mitigation is indicated or required.
CVE-2026-57236: CWE-416: Use After Free in sparklemotion nokogiri
Description
Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, calling Document#encoding= with an invalid encoding (e.g., a non-string, or a string containing a null byte) raises an exception, but only after freeing the document's current encoding string without replacing it. The document is left referencing freed memory, so the next call to Document#encoding reads invalid memory, which can cause a segfault or leak freed bytes into a Ruby String. Affects the CRuby (libxml2) implementation only; JRuby is not affected. This vulnerability is fixed in 1.19.4.
CVSS v4.0
Score 1.7low
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
CVE-2026-57236 is a use-after-free vulnerability in the Nokogiri XML and HTML library for Ruby. When Document#encoding= is called with an invalid encoding (such as a non-string or a string containing a null byte) in versions prior to 1.19.4, the current encoding string is freed without being replaced. This leaves the document referencing freed memory, causing subsequent calls to Document#encoding to read invalid memory. This can result in a segmentation fault or leaking freed bytes into a Ruby String. The vulnerability affects only the CRuby implementation using libxml2 and does not impact JRuby. The issue is resolved in Nokogiri version 1.19.4.
Potential Impact
The vulnerability can cause application crashes (segmentation faults) or memory leakage due to use-after-free conditions when handling invalid encoding inputs. This may affect application stability but does not indicate direct remote code execution or data corruption beyond memory leakage. No known exploits are reported in the wild.
Mitigation Recommendations
Upgrade Nokogiri to version 1.19.4 or later, where this use-after-free vulnerability is fixed. No other mitigation is indicated or required.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-06-24T02:21:33.812Z
- Cvss Version
- 4.0
- State
- PUBLISHED
- Remediation Level
- null
Threat ID: 6a3d3f304853345fc113d182
Added to database: 06/25/2026, 14:46:08 UTC
Last enriched: 06/25/2026, 15:01:52 UTC
Last updated: 06/25/2026, 20:18:07 UTC
Views: 3
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.