Skip to content
DoS Advisory Intermediate CVE-2023-22486

GHSL-2022-128: Quadratic complexity algorithm in cmark - CVE-2023-22486

A crafted markdown document with many repetitions of a specific character sequence triggers quadratic complexity in cmark's bracket handling, causing excessive CPU use. An attacker could use this to cause a denial-of-service on websites that render markdown with cmark.

kevinbackhouse Follow

Originally disclosed on GitHub Security Lab

A crafted markdown document can trigger a quadratic complexity algorithm in cmark.

kevinbackhouse, on GitHub Security Lab

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

Root cause

Likely, the loop in handle_close_bracket iterates over all previous openers for each closing bracket, leading to quadratic time complexity when many such brackets are present.

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

Cmark used to render untrusted markdown

The fix

The issue was fixed in cmark and cmark-gfm.

How it was found

  1. Generate a markdown document with many repetitions of the sequence '![[]()'.
  2. Pipe the document into cmark for processing.
  3. Observe that the running time increases quadratically as the number of repetitions 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.

Markdown is a simple formatting language; cmark is a program that converts it to HTML. The bug means that a specially crafted markdown file can make cmark take a very long time to process, which could slow down or crash a website that uses cmark.

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.

More by kevinbackhouse

View all

47 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.