# GHSA-p72q-h37j-3hq7: dbt uses a SQLparse version with a high vulnerability

> An attacker can cause a denial of service in dbt-core by triggering a recursion error in the bundled sqlparse library.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 22 Apr 2024

## What is GHSA-p72q-h37j-3hq7?

GHSA-p72q-h37j-3hq7 is a denial of service vulnerability in dbt-core, published on 22 Apr 2024. 

### Official description

### Summary

Using a version of `sqlparse` that has a security vulnerability and no way to update in current version of dbt core. Snyk recommends using `sqlparse==0.5` but this causes a conflict with dbt. Snyk states the issues is a recursion error: `SNYK-PYTHON-SQLPARSE-6615674`.

### Details
Dependency conflict error message:
```sh
The conflict is caused by:
    The user requested sqlparse==0.5
    dbt-core 1.7.10 depends on sqlparse<0.5 and >=0.2.3
```
Resolution was to pin `sqlparse >=0.5.0, <0.6.0` in `dbt-core`, patched in 1.6.13 and 1.7.13.

### PoC
From Snyk:

```python
import sqlparse
sqlparse.parse('[' * 10000 + ']' * 10000)
```

### Impact
Snyk classifies it as high 7.5/10.

### Patches
The bug has been fixed in [dbt-core v1.6.13](https://github.com/dbt-labs/dbt-core/releases/tag/v1.6.13) and [dbt-core v1.7.13](https://github.com/dbt-labs/dbt-core/releases/tag/v1.7.13).

### Mitigations
Bump `dbt-core` 1.6 and 1.7 dependencies to 1.6.13 and 1.7.13 respectively

## Which versions are affected by GHSA-p72q-h37j-3hq7?

4 open source packages ship an affected version, including dbt-core.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `dbt-core` | PyPI | From 1.6.0 | 1.6.13 |
| `dbt-core` | PyPI | From 1.6.0 | 1.6.13 |
| `dbt-core` | PyPI | From 1.7.0 | 1.7.13 |
| `dbt-core` | PyPI | From 1.7.0 | 1.7.13 |

## How do I fix GHSA-p72q-h37j-3hq7?

Upgrade dbt-core to a fixed version for your release line: 1.6.13 or 1.7.13.

## Is GHSA-p72q-h37j-3hq7 being exploited?

There is no known exploitation of GHSA-p72q-h37j-3hq7 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-p72q-h37j-3hq7 and fix it if it is affected.

What it is: GHSA-p72q-h37j-3hq7 is a denial of service vulnerability in dbt-core, published on 22 Apr 2024. 
Exploitation: There is no known exploitation of GHSA-p72q-h37j-3hq7 in the wild and no public exploit code.

Affected packages and fixed versions:
- dbt-core (PyPI): affected from 1.6.0; fixed in 1.6.13
- dbt-core (PyPI): affected from 1.6.0; fixed in 1.6.13
- dbt-core (PyPI): affected from 1.7.0; fixed in 1.7.13
- dbt-core (PyPI): affected from 1.7.0; fixed in 1.7.13

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-p72q-h37j-3hq7/ (Markdown: https://insights.sbomify.com/GHSA-p72q-h37j-3hq7/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-p72q-h37j-3hq7

---
From sbomify Insights: https://insights.sbomify.com/GHSA-p72q-h37j-3hq7/
Summaries are generated and may contain mistakes; the official description above is the record.
