`migrate deploy` passes the datasource URL (with password) to schema-engine in argv — readable by any local user via /proc/<pid>/cmdline
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, linux, node.js, postgresql, typescript
Research direction
Start with the two call sites named in the issue: packages/internals/src/schemaEngineCommands.ts and packages/migrate/src/SchemaEngineCLI.ts; read how each passes the datasource URL to schema-engine and the suggested JSON-RPC methods. Reproduce with the provided Docker script and check that the password no longer appears in /proc/<pid>/cmdline while migrations run. The issue names no test file, so identify relevant schema engine command tests before making a change.
Written by the indexing model from the issue text.
Description
Package and version
[email protected] (CLI, latest 7.x). Also present in [email protected], with a shorter window (see below).
What happened?
prisma migrate deploy hands the datasource URL, password included, to its schema-engine child processes as a command-line argument. On Linux, /proc/<pid>/cmdline is world-readable, so the password is visible to any local user via ps or /proc/<pid>/cmdline. On a Docker host that includes unprivileged host users looking at processes inside containers.
Two call sites, both at 7.10.1:
canConnectToDatabase→execaCommandspawnsschema-engine --datasource '{"url":"<URL>"}' cli can-connect-to-database
(schemaEngineCommands.ts#L182-L192).
It is reached viaensureDatabaseExists/ensureCanConnectToDatabase, whichmigrate deploy|dev|reset|resolve|statusanddb push|pull|dropcall.SchemaEngineCLI.internalInitstarts the JSON-RPC engine with--datasource '{"url":"<URL>"}'
(SchemaEngineCLI.ts#L389-L391).
This process stays alive for the whole command, including the time migrations take to apply.
The URL usually comes from the environment (env('DATABASE_URL') in prisma.config.ts). Only the process owner and root can read /proc/<pid>/environ, so the CLI moves the secret from a private channel to a public one. No flag or variable avoids this, because the engine accepts the URL only as an argument (--datasource <JSON>). Error output is already redacted (replace(connectionString, '<REDACTED>') in execaCommand), which leaves argv as the remaining leak.
In 5.4.2 only call site 1 carried the URL (cli --datasource <URL> can-connect-to-database). The RPC engine was started with -d schema.prisma and resolved env() itself, so the URL was exposed for a few milliseconds per command. In 7.x the long-lived engine carries the URL as well.
What did you expect to happen?
The URL should never appear in any process's argv. For example, the datasource could reach the engine over stdin through JSON-RPC: ensureConnectionValidity and createDatabase already exist as RPC methods, and the comment above canConnectToDatabase already suggests this refactor. An environment variable or an inherited file descriptor would also work, in place of --datasource.
Minimal reproduction
The script below uses only official images, and the password is a canary:
#!/bin/sh
set -eu
N=${N:-argv-demo}; V=${V:-7.10.1}
D=$(mktemp -d); cd "$D"
mkdir -p prisma/migrations/0001_init prisma/migrations/0002_slow
cat > prisma.config.ts <<'EOF'
import { defineConfig, env } from 'prisma/config'
export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: { path: 'prisma/migrations' },
datasource: { url: env('DATABASE_URL') },
})
EOF
cat > prisma/schema.prisma <<'EOF'
datasource db {
provider = "postgresql"
}
model Item {
id Int @id
}
EOF
echo 'provider = "postgresql"' > prisma/migrations/migration_lock.toml
echo 'CREATE TABLE "Item" ("id" INTEGER NOT NULL PRIMARY KEY);' > prisma/migrations/0001_init/migration.sql
echo 'SELECT pg_sleep(3); -- only makes the window easy to see' > prisma/migrations/0002_slow/migration.sql
docker network create "$N" >/dev/null
docker run -d --rm --name "$N-pg" --network "$N" --network-alias db \
-e POSTGRES_USER=app -e POSTGRES_PASSWORD=CANARYpw123 -e POSTGRES_DB=app postgres:17-alpine >/dev/null
docker run -d --rm --name "$N-cli" --network "$N" node:22-alpine sleep 600 >/dev/null
docker cp . "$N-cli:/w"
docker exec -w /w "$N-cli" sh -c "apk add -q openssl && npm init -y >/dev/null && npm i -s prisma@$V"
# An unprivileged user (nobody) polls every process's argv for 15 s.
docker exec -u nobody "$N-cli" sh -c '
end=$(( $(date +%s) + 15 ))
while [ "$(date +%s)" -lt "$end" ]; do
for f in /proc/[0-9]*/cmdline; do { tr "\0" " " < "$f"; } 2>/dev/null; echo; done | grep "[C]ANARY"
done | sort | uniq -c' &
sleep 1
docker exec -w /w -e DATABASE_URL='postgresql://app:CANARYpw123@db:5432/app' "$N-cli" npx prisma migrate deploy
wait
docker stop "$N-cli" "$N-pg" >/dev/null; docker network rm "$N" >/dev/null; rm -rf "$D"
Output with 7.10.1, after the normal migrate deploy log ("All migrations have been successfully applied."). The count is the number of polling passes in which the process was seen:
264 /w/node_modules/@prisma/engines/schema-engine-linux-musl-openssl-3.0.x --datamodels /w/prisma/schema.prisma --datasource {"url":"postgresql://app:CANARYpw123@db:5432/app"}
7 /w/node_modules/@prisma/engines/schema-engine-linux-musl-openssl-3.0.x --datasource {"url":"postgresql://app:CANARYpw123@db:5432/app"} cli can-connect-to-database
The password is readable by nobody through /proc/<pid>/cmdline. The pg_sleep(3) migration only widens the window; without it, the RPC engine is still visible for the length of the run.
With [email protected] (schema with url = env("DATABASE_URL") and no config file), the same watcher catches the cli child on every migrate deploy, including when there are no pending migrations:
13 /w/node_modules/@prisma/engines/schema-engine-linux-musl-openssl-3.0.x cli --datasource postgresql://app:CANARYpw123@db:5432/app can-connect-to-database
Environment
- Node 22.23.2 (
node:22-alpine), npm - Linux host (Ubuntu, kernel 7.0), Docker 29.8; procfs with default options (no
hidepid) - PostgreSQL 17 (
postgres:17-alpine)
Additional context
- Prisma 8 RC no longer ships the Rust schema engine, so this report covers the 7.x line (and older).
- Downstream impact: the LiteLLM proxy runs
prisma migrate deployat every boot with a bundled Prisma CLI, so on every LiteLLM host the database password appears in the process list at startup. - Workarounds today are mounting
/procwithhidepid=2, or connecting without a secret in the URL (for example over a Unix socket that only the app can reach). - #30423 is related only by call site: the same
internalInitargv causes a command-line length problem on Windows. - I did not file this through private vulnerability reporting, because exploiting it requires a local account on the machine, which SECURITY.md lists as out of scope.
- Dominant language
- TypeScript
- Stars
- 47.8k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 227
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from prisma/orm
-
bug/1-unconfirmed kind/bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
get-platform: distros with ID_LIKE=alpine are not detected as musl, so glibc engines are used on Alpine-based imagesPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
prisma/orm#31281 · 1 comment ·
Maintainers usually reply within 1 day
-
adapter-pg: connectToShadowDb connects to the main database when built from a connection stringMay be free again @cestercian claimed this 10 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
prisma/orm#31196 · 1 comment ·
Maintainers usually reply within 1 day
-
[Prisma 8] Type-check time grows exponentially with chained .include() callsPossibly taken @SiKreuz claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
prisma/orm#31161 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
prisma/orm#31125 · 4 comments · 6 reactions ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tenstorrent/ttnn-visualizer#2526 ·
Maintainers usually reply within 1 day
-
trySessionCache calls /get-session twice when minting session_data (cache miss or expired cookie)Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
neondatabase/neon-js#301 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tashfeenahmed/freellmapi#2305 ·
Maintainers usually reply within 1 day