Skip to content
DoS Advisory Intermediate CVE-2021-32837

GHSL-2021-108: ReDoS (Regular Expression Denial of Service) in mechanize - CVE-2021-32837

mechanize contains a regular expression vulnerable to ReDoS. A malicious web server can send a crafted response that causes mechanize to hang or crash.

kevinbackhouse Follow

Originally disclosed on GitHub Security Lab

mechanize contains a regular expression that is vulnerable to ReDoS (Regular Expression Denial of Service).

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 an inefficient regular expression in mechanize's HTTP handling code that exhibits catastrophic backtracking on crafted input.

Impact

This issue may lead to a denial of service.

What the attacker needed

Mechanize library used to access a malicious server

How it was found

  1. Install mechanize and flask.
  2. Run a Flask server that returns a 401 response with a crafted www-authenticate header.
  3. Run a Python script that uses mechanize to open the server URL with credentials.

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.

A regular expression is a pattern used to match text. Some patterns can take a very long time to process certain inputs, which is called a regular expression denial of service (ReDoS). Here, a malicious server can send a response that makes the mechanize library hang or crash.

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.