T08 · Insecure Dependencies
Warning
- Location
- SKILL.md:180
- Finding
- Unpinned Third-Party Codemods Executed Through npx<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:58`, `SKILL.md:180-181`, and `SKILL.md:194` **Vulnerability Type**: Unsafe use of mutable third-party package versions **Risk Level**: Medium ### Vulnerable Code ```bash npx @next/codemod@canary upgrade latest npx @next/codemod@canary next-async-request-api ``` The Skill repeats these commands elsewhere, including: ```bash npx @next/codemod@canary next-async-request-api ``` ### Technical Analysis The Skill instructs users to execute the `@next/codemod` package using `npx` and the mutable `canary` distribution tag. It also passes the mutable `latest` release selector to the upgrade codemod. When the requested package is not installed locally, `npx` can download it from the configured package registry and immediately execute its package entry point. The `canary` tag can resolve to different package versions over time, so the code ultimately executed is not fixed to the version reviewed when this Skill was published. Codemods legitimately require repository read and write access to perform migrations. However, this makes unsafe dependency resolution particularly consequential: the downloaded package runs with the invoking developer's OS privileges and can access files, environment variables, credentials available to the process, and the network. The behavior exceeds the minimum safe privilege model because no exact version, integrity verification, isolated environment, or mandatory review step is specified. This is a supply-chain exposure rather than evidence that the current official package is malicious. ### Attack Path 1. An attacker compromises the upstream package, maintainer account, publishing credentials, package registry, or mutable `canary` release channel. 2. The attacker publishes a malicious package version and causes the `canary` tag to resolve to it. 3. A developer follows the Skill and runs the documented `npx` command. 4. `npx` downloads and executes the newly resolved packa ...[truncated 1129 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace mutable `canary` and `latest` selectors with an exact, reviewed package version. 2. Record the exact dependency version and integrity information in a lockfile before execution. 3. Download or install the codemod separately, inspect its provenance, and execute only the reviewed version. 4. Run migration tools in a disposable container, sandbox, or restricted development environment without unnecessary secrets. 5. Create a clean source-control branch and ensure the working tree is committed before running a codemod. 6. Review all resulting changes with `git diff`, then run tests and static analysis before committing. 7. Configure registry allowlists and package-signature or provenance verification where supported. 8. Avoid exposing cloud, deployment, and package-publishing credentials to the codemod process. ]]>
