GHSL-2022-118: Out-of-bounds read in cmark-gfm - CVE-2023-22485
A crafted markdown document can trigger an out-of-bounds read in the validate_protocol function of cmark-gfm. The bug is considered harmless in practice because the read accesses malloc metadata without causing visible damage.
Originally disclosed on GitHub Security Lab
A crafted markdown document can trigger an out-of-bounds read in cmark-gfm.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
The out-of-bounds read is believed to be harmless in practice because it accesses malloc metadata without causing any visible damage.
What the attacker needed
Cmark-gfm with autolink extension; crafted markdown input
The fix
The issue was fixed in a temporary private fork.
How it was found
- Build cmark-gfm with AddressSanitizer enabled.
- Run the built binary with the autolink extension on a crafted markdown input.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
An out-of-bounds read happens when a program tries to read memory outside the area it was supposed to access. In this case, a specially crafted markdown document causes the cmark-gfm parser to read a few bytes before the start of a buffer. The report says this is harmless because it only reads memory management data and does not crash or leak information.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.