Skip to main content
Vulnerability Database/CVE-2026-102941

CVE-2026-102941: gomarkdown/markdown DOS Vulnerability

CVE-2026-102941 is a denial of service flaw in the gomarkdown/markdown Go library that triggers a slice-bounds panic when processing certain URL inputs. This post explains its technical details, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-102941 Overview

CVE-2026-102941 is a denial of service vulnerability in the github.com/gomarkdown/markdown Go library. The flaw resides in parser.IsSafeURL within parser/parser.go, where the code slices url[:nPath] before validating that len(url) >= nPath. Short URL destinations such as empty strings, ., or .. trigger a slice-bounds out-of-range panic [CWE-125]. The panic propagates to callers of markdown.ToHTML when rendering untrusted Markdown with html.Safelink enabled, or to any caller that passes a short attacker-controlled URL to the exported parser.IsSafeURL function. The issue is fixed in version 0.0.0-20260724235538-61af6e1e6971.

Critical Impact

An uncaught panic terminates the calling Go process, enabling remote denial of service against any service that renders attacker-controlled Markdown using the vulnerable library.

Affected Products

  • github.com/gomarkdown/markdown versions prior to 0.0.0-20260724235538-61af6e1e6971
  • Go applications calling markdown.ToHTML with html.Safelink enabled on untrusted input
  • Go applications invoking the exported parser.IsSafeURL with attacker-controlled URLs

Discovery Timeline

  • 2026-10-16 - CVE-2026-102941 published to NVD
  • 2026-10-16 - Last updated in NVD database

Technical Details for CVE-2026-102941

Vulnerability Analysis

The parser.IsSafeURL function validates whether a URL begins with a known safe relative-path prefix. The function iterates over a list of candidate Paths and compares each path of length nPath to the prefix of the input url. The pre-patch code performed the slice operation url[:nPath] before checking that the URL was long enough to be sliced safely. When the attacker-supplied URL is shorter than the candidate path length, Go raises a runtime panic for slice bounds out of range.

The one-byte destination / does not panic because it matches the first candidate path and returns early before any longer prefix slicing occurs. Confirmed panic-triggering destinations include empty strings, ., and ... Because Go panics unwind the goroutine stack and, if uncaught, terminate the process, a single malicious Markdown document can take down any server rendering it.

Root Cause

The root cause is an ordering defect in bounds validation. The length guard nLink >= nPath was evaluated after the slice expression url[:nPath], violating Go's requirement that slice indices not exceed the underlying length and capacity. The fix inverts the order: the loop now continues to the next candidate path when nLink < nPath, ensuring the slice operation only executes against sufficiently long inputs.

Attack Vector

Exploitation requires network-reachable functionality that renders untrusted Markdown with html.Safelink enabled, or an API path that forwards user input to parser.IsSafeURL. An attacker submits Markdown containing a link with an empty, ., or .. destination. The parser invokes the vulnerable comparison, panics, and crashes the handling goroutine or process. No authentication or user interaction is required.

go
// Patch for parser/parser.go - CVE-2026-102941 (GHSA-cv23-7vc5-jfh7)
	nLink := len(url)
	for _, path := range Paths {
		nPath := len(path)
-		linkPrefix := url[:nPath]
-		if nLink >= nPath && bytes.Equal(linkPrefix, path) {
+		// Length must be checked before slicing; short urls (empty, ".", "..")
+		// are shorter than some path prefixes and would panic on url[:nPath].
+		// See GHSA-cv23-7vc5-jfh7.
+		if nLink < nPath {
+			continue
+		}
+		if bytes.Equal(url[:nPath], path) {
			if nLink == nPath {
				return true
			} else if IsAlnum(url[nPath]) {

Source: gomarkdown patch commit 61af6e1e

Detection Methods for CVE-2026-102941

Indicators of Compromise

  • Unexpected Go process crashes with runtime error messages containing slice bounds out of range [:N] with length M referencing parser/parser.go.
  • Application logs showing panics inside IsSafeURL or stack traces that include gomarkdown/markdown/parser.
  • Spikes in HTTP 5xx responses from endpoints that accept Markdown input, correlated with requests containing links such as [x](), [x](.), or [x](..).

Detection Strategies

  • Perform a dependency scan across Go modules for github.com/gomarkdown/markdown at versions preceding 0.0.0-20260724235538-61af6e1e6971.
  • Inspect source code for calls to markdown.ToHTML with html.Safelink set, and any direct use of the exported parser.IsSafeURL on untrusted input.
  • Add request-body inspection rules to a web application firewall to flag Markdown links with empty, ., or .. destinations submitted to Markdown-rendering endpoints.

Monitoring Recommendations

  • Monitor process restart counts and crash loop metrics for services that handle user-generated Markdown.
  • Forward Go panic stack traces to centralized logging and alert on patterns matching IsSafeURL or parser.go slice-bounds errors.
  • Track request-to-crash correlation using unique request IDs to attribute panics to specific inbound payloads.

How to Mitigate CVE-2026-102941

Immediate Actions Required

  • Upgrade github.com/gomarkdown/markdown to version 0.0.0-20260724235538-61af6e1e6971 or later across all Go modules using go get -u github.com/gomarkdown/markdown followed by go mod tidy.
  • Rebuild and redeploy all services that embed the library; a module update alone does not patch running binaries.
  • Audit all code paths that pass untrusted input to markdown.ToHTML or parser.IsSafeURL and prioritize those exposed to unauthenticated users.

Patch Information

The upstream fix is published in the GitHub Security Advisory GHSA-cv23-7vc5-jfh7 and committed as patch 61af6e1e. The fix adds a nLink < nPath guard before slicing, eliminating the panic condition for short URLs.

Workarounds

  • Disable html.Safelink rendering until the library is upgraded, which removes the primary path to IsSafeURL from markdown.ToHTML.
  • Wrap calls to markdown.ToHTML and parser.IsSafeURL in a defer/recover block to prevent panics from terminating the process, accepting that this is a stopgap and not a true fix.
  • Pre-filter inbound Markdown at the application edge to reject link destinations shorter than three bytes or matching . and .. exactly.
bash
# Upgrade the vulnerable module and rebuild
go get github.com/gomarkdown/markdown@v0.0.0-20260724235538-61af6e1e6971
go mod tidy
go build ./...

# Verify the resolved version
go list -m github.com/gomarkdown/markdown

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.