Skip to content
DoS Advisory Intermediate CVE-2023-22484

GHSL-2022-098: Quadratic complexity algorithm in cmark - CVE-2023-22484

A crafted markdown document with many repetitions of the characters '<!--' triggers quadratic complexity in cmark's HTML comment scanner, causing excessive CPU usage. 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 HTML comment scanner is called repeatedly for each '<' character and scans to the end of the line, leading to quadratic time complexity.

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; attacker can submit crafted markdown

The fix

The bug was fixed by the maintainer.

How it was found

  1. Generate a markdown document containing many repetitions of '<!--'.
  2. Pipe the document into cmark.
  3. Observe that 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.

This is a denial-of-service bug. When cmark processes a specially crafted markdown file, it takes much longer than it should, growing quadratically with the input size. An attacker could send such a file to a website that uses cmark, making the server slow or unresponsive.

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.