CVE-2026-102941: Github.com/gomarkdown/markdown Gomarkdown/markdown IsSafeURL Panics On Short Vulnerability

HIGH
Advisory Identifier: GHSA-cv23-7vc5-jfh7
CVSS 7.5
CWE-125
Published
Advisory Summary

CVE-2026-102941 is a HIGH (CVSS 7.5) gomarkdown/markdown issafeurl panics on short vulnerability (CWE-125: Out-of-bounds Read) affecting Github.com/gomarkdown/markdown libraries in the Go ecosystem. The issue involves gomarkdown/markdown issafeurl panics on short urls. Remediation is available by upgrading affected packages to version 0.0.0-20260724235538-61af6e1e6971.

CVE-2026-102941 at a Glance

CVE Identifier CVE-2026-102941
GHSA Identifier GHSA-cv23-7vc5-jfh7
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-125: Out-of-bounds Read
Affected Product Github.com/gomarkdown/markdown
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2026-102941

To remediate this vulnerability, upgrade all affected Github.com/gomarkdown/markdown dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/gomarkdown/markdown fixed: 0.0.0-20260724235538-61af6e1e6971
Upgrade github.com/gomarkdown/markdown to 0.0.0-20260724235538-61af6e1e6971
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/gomarkdown/markdown

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-102941, inspect your project dependencies for Github.com/gomarkdown/markdown:

inspect dependencies for github.com/gomarkdown/markdown

Analyze the terminal output to locate any version of Github.com/gomarkdown/markdown in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.0.0-20260724235538-61af6e1e6971), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-125: Out-of-bounds Read, where the product reads data past the end, or before the beginning, of the intended buffer. In Github.com/gomarkdown/markdown, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary 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: ```go 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). ## Suggested fix 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). ## 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.

CVE-2026-102941 Affected Github.com/gomarkdown/markdown Versions

1 component(s)
Fixed Versions:
0.0.0-20260724235538-61af6e1e6971
Product / Package Ecosystem Affected Versions Fixed Version
github.com/gomarkdown/markdown
Go
< 0.0.0-20260724235538-61af6e1e6971
0.0.0-20260724235538-61af6e1e6971

References

Frequently Asked Questions

What is CVE-2026-102941?
CVE-2026-102941 is a security vulnerability in Github.com/gomarkdown/markdown involving gomarkdown/markdown IsSafeURL panics on short URLs under CWE-125: Out-of-bounds Read.
Which Github.com/gomarkdown/markdown versions are affected?
Affected versions include releases prior to 0.0.0-20260724235538-61af6e1e6971 across affected packages: github.com/gomarkdown/markdown.
What version fixes CVE-2026-102941?
Upgrading to 0.0.0-20260724235538-61af6e1e6971 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/gomarkdown/markdown affected?
Yes, github.com/gomarkdown/markdown is affected in releases prior to 0.0.0-20260724235538-61af6e1e6971. Upgrade your dependency to 0.0.0-20260724235538-61af6e1e6971 or later.
What is the CVSS score of CVE-2026-102941?
CVE-2026-102941 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-102941?
CVE-2026-102941 is classified under CWE-125: Out-of-bounds Read (The product reads data past the end, or before the beginning, of the intended buffer.).
How can I check Go dependencies for CVE-2026-102941?
Run the dependency tree command: 'inspect dependencies for github.com/gomarkdown/markdown'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-cv23-7vc5-jfh7",
  "modified" : "2026-10-16T15:41:39Z",
  "published" : "2026-10-16T15:41:39Z",
  "aliases" : [ "CVE-2026-102941" ],
  "summary" : "gomarkdown/markdown IsSafeURL panics on short URLs",
  "details" : "## Summary\n\nIsSafeURL 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).\n\n## The defect\n\nparser/parser.go, IsSafeURL:\n\n```go\nfunc IsSafeURL(url []byte) bool {\n    nLink := len(url)\n    for _, path := range validPaths {          // \"/\", \"./\", \"../\"\n        nPath := len(path)\n        linkPrefix := url[:nPath]               // line 789: sliced BEFORE the length guard\n        if nLink >= nPath && bytes.Equal(linkPrefix, path) {   // line 790: guard is too late\n            ...\n```\n\nurl[: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.\n\n## Verification\n\nEXECUTED 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).\n\n## Suggested fix\n\nMove 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.\n\nAlso 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).\n\n## Tooling\n\nAI 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/gomarkdown/markdown"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.0.0-20260724235538-61af6e1e6971"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gomarkdown/markdown/security/advisories/GHSA-cv23-7vc5-jfh7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gomarkdown/markdown/commit/61af6e1e69710c5ca13cfbaaaa1bc11bc763a8a9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gomarkdown/markdown"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-125" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-16T15:41:39Z",
    "nvd_published_at" : null
  }
}