CVE-2026-102941

CVE-2026-102941 is a high-severity out-of-bounds read vulnerability in github.com/gomarkdown/markdown (go), affecting versions < 0.0.0-20260724235538-61af6e1e6971. It is fixed in 0.0.0-20260724235538-61af6e1e6971.

Does this CVE actually affect you?

Kodem shows which CVEs are reachable and running in your applications, so you fix what's exploitable, not just what's listed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence, not another scanner.

Summary

gomarkdown/markdown IsSafeURL panics on short URLs

IsSafeURL slices url[:nPath] before checking that len(url) >= nPath, so a URL shorter than a path prefix (0, 1 or 2 bytes) triggers a slice-bounds panic, and this is reached end to end when the html.Safelink hardening flag is enabled and the input contains an empty or very short link destination, giving an unrecoverable crash DoS. Confirmed at HEAD (e08cff8; present since 2022).

The defect

parser/parser.go, IsSafeURL:

func IsSafeURL(url []byte) bool {
    nLink := len(url)
    for _, path := range validPaths {          // "/", "./", "../"
        nPath := len(path)
        linkPrefix := url[:nPath]               // line 789: sliced BEFORE the length guard
        if nLink >= nPath && bytes.Equal(linkPrefix, path) {   // line 790: guard is too late
            ...

url[:nPath] is evaluated before the nLink >= nPath check. When len(url) < nPath and cap(url) < nPath, the slice expression panics. Only the relative-path loop is affected; the adjacent URIs loop is already correctly guarded (the signal that this one deviates, the same signal as the anchor). Input: IsSafeURL("") panics ([:1] cap 0), IsSafeURL(".") panics ([:2] cap 1), IsSafeURL("..") panics ([:3] cap 2), while IsSafeURL("/") returns true. End to end: markdown.ToHTML(input, html.CommonFlags|html.Safelink) with input [x]() panics. Attacker model: (1) any service rendering untrusted Markdown with the html.Safelink flag (the URL-sanitizing hardening flag itself introduces the crash); or (2) any downstream that calls the exported parser.IsSafeURL on a 0/1/2-byte attacker URL, no flag required. No recover() anywhere, so an uncaught crash of the calling goroutine.

Verification

EXECUTED with negative controls. Direct: the empty/1/2-char cases panic with the exact slice-bounds message while "/" returns true. End to end via ToHTML with html.CommonFlags|html.Safelink: [x]() panics, while [x](/), [x](http://example.com), plain text, and [x](javascript:alert(1)) (safely dropped) do not. NOT verified: how many downstream apps enable Safelink or call IsSafeURL directly (the default no-Safelink render path does not reach it).

Tooling

AI assistance was used while investigating. The panic is executed-verified with negative controls (IsSafeURL on empty/./.. panics with a slice-bounds error while "/" returns true; ToHTML with html.Safelink on [x]() panics while valid and javascript: links do not), and I confirmed at HEAD that IsSafeURL computes url[:nPath] before the nLink >= nPath guard.

Impact

A read operation accesses a memory location beyond the intended buffer boundary. Typical impact: sensitive data disclosure or crash.

CVE-2026-102941 has a CVSS score of 7.5 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (0.0.0-20260724235538-61af6e1e6971); upgrading removes the vulnerable code path.

Affected versions

github.com/gomarkdown/markdown (< 0.0.0-20260724235538-61af6e1e6971)

Security releases

github.com/gomarkdown/markdown → 0.0.0-20260724235538-61af6e1e6971 (go)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

Move the slice inside the guard: check nLink >= nPath first, then compute url[:nPath] (or use bytes.HasPrefix(url, path), which is length-safe). One-line change, mirroring the already-correct URIs loop.

Also checked and sound: CVE-2026-40890 (smartypants smartLeftAngle OOB) is fixed; CVE-2024-44337 (list/paragraph infinite loop) is fixed (deep nesting capped at maxNesting=64); default XSS is by design (Safelink/SkipHTML not in CommonFlags).

Frequently Asked Questions

  1. What is CVE-2026-102941? CVE-2026-102941 is a high-severity out-of-bounds read vulnerability in github.com/gomarkdown/markdown (go), affecting versions < 0.0.0-20260724235538-61af6e1e6971. It is fixed in 0.0.0-20260724235538-61af6e1e6971. A read operation accesses a memory location beyond the intended buffer boundary.
  2. How severe is CVE-2026-102941? CVE-2026-102941 has a CVSS score of 7.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which versions of github.com/gomarkdown/markdown are affected by CVE-2026-102941? github.com/gomarkdown/markdown (go) versions < 0.0.0-20260724235538-61af6e1e6971 is affected.
  4. Is there a fix for CVE-2026-102941? Yes. CVE-2026-102941 is fixed in 0.0.0-20260724235538-61af6e1e6971. Upgrade to this version or later.
  5. Is CVE-2026-102941 exploitable, and should I be worried? Whether CVE-2026-102941 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2026-102941 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2026-102941? Upgrade github.com/gomarkdown/markdown to 0.0.0-20260724235538-61af6e1e6971 or later.

Other vulnerabilities in github.com/gomarkdown/markdown

Stop the waste.
Protect your environment with Kodem.