Advisory Database
  • Advisories
  • Dependency Scanning
  1. gem
  2. ›
  3. nokogiri
  4. ›
  5. GHSA-wjv4-x9w8-wm3h

GHSA-wjv4-x9w8-wm3h: Nokogiri: Possible Use-After-Free when setting `Document#root=` to an invalid node type

June 19, 2026

Nokogiri::XML::Document#root= validated only that the new root was a Nokogiri::XML::Node, allowing a DTD node to be set as the document root. The result is a heap use-after-free during garbage collection or finalization, leading to an invalid memory read or potentially a segfault.

Nokogiri 1.19.4 restricts Document#root= to element nodes, raising TypeError for any other node type.

This memory-safety issue affects only the CRuby implementation (libxml2). The JRuby implementation was not affected; the same input validation was added there for behavioral parity.

References

  • github.com/advisories/GHSA-wjv4-x9w8-wm3h
  • github.com/sparklemotion/nokogiri/security/advisories/GHSA-wjv4-x9w8-wm3h

Code Behaviors & Features

Detect and mitigate GHSA-wjv4-x9w8-wm3h with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

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-wjv4-x9w8-wm3h.yml

Spotted a mistake? Edit the file on GitLab.

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

Page generated Tue, 23 Jun 2026 12:23:39 +0000.