GHSL-2023-031: Quadratic complexity algorithm in cmark - CVE-2023-24824
A crafted markdown document with a deeply nested list followed by many empty lines causes cmark to run in quadratic time, leading to a denial of service. An attacker could exploit this to make a website that renders markdown unresponsive.
Originally disclosed on GitHub Security Lab
A crafted markdown document can trigger a quadratic complexity algorithm in cmark.
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
This issue could be used in a denial-of-service attack on websites that use cmark to render markdown documents.
What the attacker needed
Website uses cmark to render markdown; attacker can submit crafted markdown
The fix
The issue was fixed in cmark-gfm version 0.29.0.gfm.11 and a pull request was created for cmark.
How it was found
- Create a markdown document with a deeply nested list followed by many empty lines.
- Feed the document to cmark for parsing.
- Observe that the running time increases quadratically as the number of nested items and empty lines grows.
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.
cmark is a program that converts markdown text into HTML. If someone gives it a specially crafted document with a very long nested list and many blank lines, the program takes much longer to process it than normal, which can slow down or crash a website that uses it.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.