GHSL-2023-001: ReDoS in SQLparse - CVE-2023-30608
The SQL parser library sqlparse uses regular expressions for string literals that are vulnerable to catastrophic backtracking. An attacker could supply a crafted SQL string to cause excessive CPU consumption and a denial of service.
Originally disclosed on GitHub Security Lab
SQLparse has a ReDoS (regular expression denial of service) in the parser for SQL expressions.
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
What the attacker needed
Attacker-controlled SQL string passed to sqlparse
The fix
The vulnerability was fixed in a patched release.
How it was found
- Import the sqlparse library.
- Create a string containing many backslashes and a leading single quote.
- Pass the string to sqlparse.format().
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 fail on certain inputs, which is called a ReDoS. Here, a specially crafted SQL string makes the parser work extremely hard, so the application becomes 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.