Location: packages/server/src/integrations/postgres.ts:529-531
The PostgreSQL integration constructs shell commands using user-controlled configuration values (database name, host, password, etc.) without proper sanitization. The password and other connection parameters are directly interpolated into a shell command.
const dumpCommand = `PGPASSWORD="${
this.config.password
}" pg_dump --schema-only "${dumpCommandParts.join(" ")}"`
An attacker who can control database configuration values (e.g., through compromised credentials or configuration injection) can inject shell commands. For example:
password"; malicious-command; echo "db"; rm -rf /; echo "import { execFile } from "child_process"
import { promisify } from "util"
const execFileAsync = promisify(execFile)
// Use execFile with proper argument handling
const env = {
...process.env,
PGPASSWORD: this.config.password
}
const args = [
"--schema-only",
"--host", this.config.host,
"--port", this.config.port.toString(),
"--username", this.config.user,
"--dbname", this.config.database
]
try {
const { stdout } = await execFileAsync("pg_dump", args, { env })
return stdout
} catch (error) {
// Handle error
}
{
"cwe_ids": [
"CWE-77",
"CWE-78"
],
"github_reviewed": true,
"github_reviewed_at": "2026-03-09T16:56:26Z",
"nvd_published_at": "2026-03-09T20:16:07Z",
"severity": "HIGH"
}