# CVE-2024-40637: Implicit override for built-in materializations from installed packages in dbt-core

> Malicious dbt packages can implicitly override built-in materializations to execute arbitrary code, requiring users to upgrade dbt-core.

- **Severity:** Medium 4.2 (`CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 16 Jul 2024
- **Updated:** 2 Aug 2024
- **Also known as:** GHSA-p3f3-5ccg-83xq, PYSEC-2024-66

## What is CVE-2024-40637?

CVE-2024-40637 is a medium-severity code injection vulnerability in dbt-labs dbt-core, published on 16 Jul 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

dbt enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications. When a user installs a package in dbt, it has the ability to override macros, materializations, and other core components of dbt. This is by design, as it allows packages to extend and customize dbt's functionality. However, this also means that a malicious package could potentially override these components with harmful code. This issue has been fixed in versions 1.8.0, 1.6.14 and 1.7.14. Users are advised to upgrade. There are no kn own workarounds for this vulnerability. Users updating to either 1.6.14 or 1.7.14 will need to set `flags.require_explicit_package_overrides_for_builtin_materializations: False` in their configuration in `dbt_project.yml`.

Weakness: CWE-89 (Improper Neutralization of Special Elements used in an SQL Command), CWE-74 (Improper Neutralization of Special Elements in Output Used by a Downstream Component)

## Which versions are affected by CVE-2024-40637?

5 open source packages ship an affected version, including dbt-core. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `dbt-core` | PyPI | From 1.6.0 | 1.6.14 |
| `dbt-core` | PyPI | From 1.6.0 | 1.6.14 |
| `dbt-core` | PyPI | From 1.7.0 | 1.7.14, 1.6.14 |
| `dbt-core` | PyPI | From 1.7.0 | 1.7.14 |
| `dbt-core` | PyPI | From 1.7.0 | 1.7.14 |

Products: Getdbt Dbt Core.

## How do I fix CVE-2024-40637?

Upgrade dbt-core to a fixed version for your release line: 1.6.14 or 1.7.14.

## Is CVE-2024-40637 being exploited?

There is no known exploitation of CVE-2024-40637 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-40637 and fix it if it is affected.

What it is: CVE-2024-40637 is a medium-severity code injection vulnerability in dbt-labs dbt-core, published on 16 Jul 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2024-40637 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.14
- dbt-core (PyPI): affected from 1.6.0; fixed in 1.6.14
- dbt-core (PyPI): affected from 1.7.0; fixed in 1.7.14, 1.6.14
- dbt-core (PyPI): affected from 1.7.0; fixed in 1.7.14
- dbt-core (PyPI): affected from 1.7.0; fixed in 1.7.14

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/CVE-2024-40637/ (Markdown: https://insights.sbomify.com/CVE-2024-40637/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-40637
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-40637
- OSV: https://osv.dev/vulnerability/CVE-2024-40637

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-40637/
Summaries are generated and may contain mistakes; the official description above is the record.
