# CVE-2023-42821: github.com/gomarkdown/markdown Out-of-bounds Read while parsing citations

> An attacker can cause a denial of service in applications using the gomarkdown library by providing malformed input when the Mmark extension is enabled.

- **Severity:** High 7.5 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 22 Sep 2023
- **Updated:** 24 Sep 2024
- **Also known as:** AZL-39828, CLEANSTART-2026-DC83183, DEBIAN-CVE-2023-42821, GHSA-m9xq-6h2j-65r2, GO-2023-2074, UBUNTU-CVE-2023-42821

## What is CVE-2023-42821?

CVE-2023-42821 is a high-severity denial of service vulnerability in gomarkdown markdown, published on 22 Sep 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

The package `github.com/gomarkdown/markdown` is a Go library for parsing Markdown text and rendering as HTML. Prior to pseudoversion `0.0.0-20230922105210-14b16010c2ee`, which corresponds with commit `14b16010c2ee7ff33a940a541d993bd043a88940`, parsing malformed markdown input with parser that uses parser.Mmark extension could result in out-of-bounds read vulnerability. To exploit the vulnerability, parser needs to have `parser.Mmark` extension set. The panic occurs inside the `citation.go` file on the line 69 when the parser tries to access the element past its length. This can result in a denial of service. Commit `14b16010c2ee7ff33a940a541d993bd043a88940`/pseudoversion `0.0.0-20230922105210-14b16010c2ee` contains a patch for this issue.

Weakness: CWE-125 (Out-of-bounds Read)

## Which versions are affected by CVE-2023-42821?

3 open source packages ship an affected version, including github.com/gomarkdown/markdown. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/gomarkdown/markdown` | Go | All versions | 0.0.0-20230922105210-14b16010c2ee |
| `github.com/gomarkdown/markdown` | Go | All versions | 0.0.0-20230922105210-14b16010c2ee |
| `github.com/gomarkdown/markdown` | Go | All versions | 0.0.0-20230922105210-14b16010c2ee |

Products: Gomarkdown Markdown.

## How do I fix CVE-2023-42821?

Upgrade github.com/gomarkdown/markdown to 0.0.0-20230922105210-14b16010c2ee or later.

## Is CVE-2023-42821 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-42821 exists.

## Other vulnerabilities in gomarkdown markdown

- [CVE-2026-40890](https://insights.sbomify.com/CVE-2026-40890/): github.com/gomarkdown/markdown: Out-of-bounds Read in SmartypantsRenderer (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-42821 and fix it if it is affected.

What it is: CVE-2023-42821 is a high-severity denial of service vulnerability in gomarkdown markdown, published on 22 Sep 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-42821 exists.

Affected packages and fixed versions:
- github.com/gomarkdown/markdown (Go): affected all versions; fixed in 0.0.0-20230922105210-14b16010c2ee
- github.com/gomarkdown/markdown (Go): affected all versions; fixed in 0.0.0-20230922105210-14b16010c2ee
- github.com/gomarkdown/markdown (Go): affected all versions; fixed in 0.0.0-20230922105210-14b16010c2ee

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-42821/ (Markdown: https://insights.sbomify.com/CVE-2023-42821/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-42821
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-42821
- OSV: https://osv.dev/vulnerability/CVE-2023-42821

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-42821/
Summaries are generated and may contain mistakes; the official description above is the record.
