Your RSA-2048 keys break in 2030. Find every one of them before attackers do.
🐍
🐍 PyPI
Not in CISA KEV
HIGH severity

GHSA-p5w8-wqhj-9hhf

HIGHFix: andialbrecht/sqlparse@8238a9e

GHSA-p5w8-wqhj-9hhf is a high-severity (CVSS 7.5) Uncontrolled Resource Consumption vulnerability in sqlparse. O3 Security confirms whether GHSA-p5w8-wqhj-9hhf is actually reachable in your code before you act, and blocks exploitation at runtime until you patch.

StripComments filter contains a regular expression that is vulnerable to ReDOS (Regular Expression Denial of Service)

Also known asCVE-2021-32839PYSEC-2021-333
Published
Sep 10, 2021
Updated
Jul 8, 2026
Affected
1 pkg
Patched
1 / 1
Exploits
None indexed
Exploitation data as of Jul 8, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

Real-World Exposure

1 pkg affected
🐍sqlparse

Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.

Description

Impact

The formatter function that strips comments from a SQL contains a regular expression that is vulnerable to ReDoS (Regular Expression Denial of Service). The regular expression may cause exponential backtracking on strings containing many repetitions of '\r\n' in SQL comments.

Patches

The issues has been fixed in sqlparse 0.4.2.

Workarounds

Only the formatting feature that removes comments from SQL statements is affected by this regular expression. As a workaround don't use the sqlformat.format function with keyword strip_comments=True or the --strip-comments command line flag when using the sqlformat command line tool.

References

This issue was discovered by GitHub team members @erik-krogh and @yoff. It was found using a CodeQL query which identifies inefficient regular expressions. You can see the results of the query on python-sqlparse by following this link.

For more information

If you have any questions or comments about this advisory:

Affected Packages

1 total 1 fixed
EcosystemPackageVulnerable rangeFix
🐍PyPIsqlparse0.4.0&&< 0.4.20.4.2

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for sqlparse. O3's reachability analysis confirms whether the vulnerable code path is actually invoked in your application, so you act on real exposure instead of every transitive match.

  2. Fix

    Update sqlparse to 0.4.2 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-p5w8-wqhj-9hhf is resolved across your whole dependency graph.

  3. Workarounds

    If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.

  4. How O3 protects you

    O3 pinpoints whether GHSA-p5w8-wqhj-9hhf is reachable in your code and exactly where to fix it, then blocks exploitation in production at runtime until the patched version is deployed.

Tailored to GHSA-p5w8-wqhj-9hhf. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.

Frequently Asked Questions

### Impact The formatter function that strips comments from a SQL contains a regular expression that is vulnerable to [ReDoS](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS) (Regular Expression Denial of Service). The regular expression may cause exponential backtracking on strings containing many repetitions of '\r\n' in SQL comments. ### Patches The issues has been fixed in sqlparse 0.4.2. ### Workarounds Only the formatting feature that removes comments from SQL statements is affected by this regular expression. As a workaround don't use the `sqlforma
O3 Security · Impact-Aware SCA

Is GHSA-p5w8-wqhj-9hhf in your dependencies?

O3 detects GHSA-p5w8-wqhj-9hhf across PyPI dependencies and uses function-level reachability to confirm whether the vulnerable code path is actually reachable — not just present. No false positives.

GHSA-p5w8-wqhj-9hhf: sqlparse Denial of… | O3 Security