T08 · Insecure Dependencies
- Location
scripts/check-prisma-migrate.sh:34- Finding
Unpinned Prisma Package Download and Execution via npx
- Content
View full analysis
Vulnerability Details
File Location:
scripts/check-prisma-migrate.sh, line 34
Vulnerability Type: Supply-chain risk caused by automatic execution of an unpinned dependency
Risk Level: MediumVulnerable Code:
bash STATUS_OUTPUT="" if ! STATUS_OUTPUT="$(npx --yes prisma migrate status --schema "$SCHEMA_PATH" 2>&1)"; then echo "$STATUS_OUTPUT" fail "prisma migrate status failed" fiTechnical Analysis
The script invokes
npx --yes prismawithout specifying a reviewed package version or requiring a lockfile-installed local binary. If Prisma is not already installed locally,npx --yesmay automatically retrieve and execute the package resolved through the active npm registry and npm configuration.This makes the code executed by the guard dependent on mutable external package resolution rather than solely on the audited project contents. The effective executable can change after this Skill has been reviewed. A compromised registry, malicious package release, altered npm registry configuration, or dependency-resolution attack could therefore cause attacker-controlled package lifecycle or runtime code to execute.
The command is run during a deployment or CI preflight check, where the process is expected to have access to the selected database URL environment variable and potentially other deployment credentials.
Attack Path
- An attacker compromises or influences the npm registry, Prisma package release, or npm configuration used by the CI/deployment environment.
- The expected local Prisma executable is absent, causing
npxto resolve the package remotely. - The migration guard executes
npx --yes prisma migrate statuswithout a pinned version or interactive confirmation. npxdownloads and executes the attacker-influenced package.- Malicious package code runs with the permissions, environment variables, network access, and filesystem access of the CI or deployment ac ...[truncated 902 chars]
- Remediation
View remediation
Remediation Suggestions
- Declare a reviewed, exact Prisma version in the project dependencies and commit the associated lockfile.
- Install dependencies in CI using an immutable or frozen-lockfile mode, such as
npm ci. - Invoke the lockfile-installed binary directly:
bash ./node_modules/.bin/prisma migrate status --schema "$SCHEMA_PATH" - Alternatively, use
npx --no-install prisma ...where supported so execution fails instead of downloading a missing package. - Configure an approved npm registry and enforce package integrity and provenance controls.
- Run the guard under a least-privileged account with access only to the database and files required for migration-status inspection.
- Limit secrets exposed to the CI step and restrict unnecessary outbound network access after dependencies have been installed.
