Advisory Database
  • Advisories
  • Dependency Scanning
  1. gem
  2. ›
  3. nokogiri
  4. ›
  5. GHSA-5v8h-3h3q-446p

GHSA-5v8h-3h3q-446p: Nokogiri: Possible Use-After-Free when `Nokogiri::XML::Document#encoding=` raises an exception

June 19, 2026

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.

References

  • github.com/advisories/GHSA-5v8h-3h3q-446p
  • github.com/sparklemotion/nokogiri/security/advisories/GHSA-5v8h-3h3q-446p

Code Behaviors & Features

Detect and mitigate GHSA-5v8h-3h3q-446p with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →

Affected versions

All versions before 1.19.4

Fixed versions

  • 1.19.4

Solution

Upgrade to version 1.19.4 or above.

Impact 5.3 MEDIUM

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

Learn more about CVSS

Weakness

  • CWE-416: Use After Free

Source file

gem/nokogiri/GHSA-5v8h-3h3q-446p.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Sun, 08 Nov 2026 00:16:16 +0000.