# CVE-2026-57236: Nokogiri: Possible Use-After-Free when \`Nokogiri::XML::Document\#encoding=\` raises an exception

- Priority: **Routine**
- Reason: Not severe (CVSS 1.7, network access); no exploitation reported by the 5 checked sources
- Next step: Fix in the normal cadence
- Status: published
- Published: 2026-06-25 · Modified: 2026-06-25
- Aliases: UBUNTU-CVE-2026-57236, DEBIAN-CVE-2026-57236, GHSA-5v8h-3h3q-446p, ALPINE-CVE-2026-57236
- Record: https://cvemate.com/vulnerability/CVE-2026-57236 · JSON: https://cvemate.com/vulnerability/CVE-2026-57236/json

## Description

```text
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.
```

## Signals

- CVSS: 8.2 high (v3.1, NVD) CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:H
- EPSS: 0.341%, percentile 29.52%, as of 2026-12-04
- Known exploited (KEV): CISA not listed, ENISA not listed, CIRCL not listed
- Ransomware use: none recorded
- Public exploits: 0

## Affected

- alpine ruby-nokogiri (Alpine Linux): \< 1.19.4-r0
- debian ruby-nokogiri (Debian): All versions (No fix recorded) \| \< 1.19.4+dfsg-1
- ubuntu ruby-nokogiri (Ubuntu): All versions (No fix recorded)
- RubyGems nokogiri (RubyGems): \< 1.19.4
- nokogiri nokogiri: \< 1.19.4
- sparklemotion nokogiri: \< 1.19.4

## References

- <https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-5v8h-3h3q-446p>
- <https://ubuntu.com/security/CVE-2026-57236>
- <https://www.cve.org/CVERecord?id=CVE-2026-57236>
- <https://security-tracker.debian.org/tracker/CVE-2026-57236>
- <https://github.com/sparklemotion/nokogiri>
- <https://nvd.nist.gov/vuln/detail/CVE-2026-57236>
- <https://security.alpinelinux.org/vuln/CVE-2026-57236>

---

Data as of 2026-12-05T08:28:35.637Z. The priority label is CveMate's own model from public evidence, not an official rating, and it knows nothing about your assets. How labels are decided: https://cvemate.com/faq#priority
