Skip to content
Heist/ feed
Back to feed
Low

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

Type: advisorySources: OSV

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2026-57236
Confirmed fixed CVEs
Not specified
Updated in this feed
4 Nov 2026, 13:23 UTC · Revision 1

Source evidence

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

core-osv · Original source

Published 25 Jun 2026, 14:29 UTC

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.

osv:CVE-2026-57236
Complete source record
{
  "id": "036962db381cc481417c0843ff77b2c0095746a7bb35be1bef005cc97a5971b0",
  "url": "https://osv.dev/vulnerability/CVE-2026-57236",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "Nokogiri: Possible Use-After-Free when `Nokogiri::XML::Document#encoding=` raises an exception",
    "summary": "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.",
    "evidence": "osv:CVE-2026-57236",
    "products": [],
    "severity": "low",
    "structured": {
      "id": "CVE-2026-57236",
      "aliases": [
        "CVE-2026-57236",
        "GHSA-5v8h-3h3q-446p"
      ],
      "metrics": [
        {
          "type": "CVSS_V4",
          "score": "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"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/sparklemotion/nokogiri",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "8cfb9daae9ee4a0837508eab43c40fbc8c4138c9"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "1.19.4"
                      }
                    ],
                    "source": "AFFECTED_FIELD",
                    "strategy": "StringRangeExpression"
                  },
                  {
                    "cpe": "cpe:2.3:a:nokogiri:nokogiri:*:*:*:*:*:ruby:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "1.19.4"
                      }
                    ],
                    "source": "CPE_RANGE"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v1.19.3",
            "v1.19.2",
            "v1.19.1",
            "v1.19.0",
            "v1.18.10",
            "v1.18.9",
            "v1.18.8",
            "v1.18.7",
            "v1.18.6",
            "v1.18.5",
            "v1.18.4",
            "v1.18.3",
            "v1.18.2",
            "v1.18.1",
            "v1.18.0",
            "v1.18.0.rc1",
            "v1.17.0",
            "v1.16.0",
            "v1.16.0.rc1",
            "v1.15.2",
            "v1.15.1",
            "v1.15.0",
            "v1.14.1",
            "v1.14.0",
            "v1.14.0.rc1",
            "v1.13.0",
            "v1.12.3",
            "v1.12.2",
            "v1.12.1",
            "v1.12.0",
            "v1.12.0.rc1",
            "v1.11.3",
            "v1.11.2",
            "v1.11.1",
            "v1.11.0",
            "v1.11.0.rc4",
            "v1.11.0.rc3",
            "v1.11.0.rc2",
            "v1.11.0.rc1",
            "v1.10.3",
            "v1.10.2",
            "v1.8.5",
            "v1.10.1",
            "v1.10.0",
            "v1.10.0.rc1",
            "v1.9.1",
            "v1.9.0",
            "v1.9.0.rc1",
            "v1.8.4",
            "v1.8.3",
            "v1.8.2",
            "v1.8.1",
            "v1.8.0",
            "v1.7.0.1",
            "v1.7.0",
            "v1.6.8",
            "v1.6.8.rc3",
            "v1.6.8.rc2",
            "v1.6.8.rc1",
            "v1.6.7.rc4",
            "v1.6.6.2",
            "v1.6.7.rc3",
            "v1.6.7.rc2",
            "v1.6.7.rc1",
            "1.7.0.1-linux-binary1",
            "v1.6.6.1",
            "v1.6.6",
            "v1.6.5",
            "v1.6.4",
            "v1.6.3.1",
            "v1.6.3",
            "v1.6.3.rc3",
            "v1.6.3.rc2",
            "v1.6.3.rc1",
            "v1.6.2.1",
            "v1.6.2",
            "v1.6.2.rc3",
            "v1.6.2.rc1",
            "v1.6.2.beta.1",
            "v1.6.0",
            "v1.5.9",
            "v1.6.0.rc1",
            "v1.5.8",
            "v1.5.7",
            "v1.5.7.rc3",
            "v1.5.7.rc2",
            "v1.5.7.rc1",
            "v1.5.6",
            "v1.5.6.rc2",
            "v1.5.5.rc2",
            "v1.5.5.rc1",
            "v1.5.4.rc3",
            "v1.5.4.rc2",
            "v1.5.4.rc1",
            "v1.5.3",
            "v1.5.3.rc6",
            "v1.5.3.rc5",
            "v1.5.3.rc4",
            "v1.5.3.rc3",
            "v1.5.3.rc1",
            "v1.5.2",
            "v1.5.1",
            "v1.5.1.rc1",
            "v1.5.0",
            "v1.5.0.beta.3",
            "v1.5.0.beta.4",
            "REL_1.5.0.beta.2",
            "REL_1.5.0.beta.1",
            "REL_1.0.7",
            "REL_1.0.6",
            "REL_1.0.5",
            "REL_1.0.4",
            "REL_1.0.3",
            "REL_1.0.2",
            "REL_1.0.1",
            "REL_1.0.0"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-57236.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:35.670155163Z",
      "provider": "osv",
      "references": [
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/57xxx/CVE-2026-57236.json",
        "https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-5v8h-3h3q-446p",
        "https://nvd.nist.gov/vuln/detail/CVE-2026-57236"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-416"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/57xxx/CVE-2026-57236.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2026-57236",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 503042,
  "published_at": "2026-06-25T14:29:14.181+00:00"
}