T08 · Insecure Dependencies
- Location
scripts/post-edit-check.sh:29- Finding
Automatic execution of an unpinned package through npx
- Content
View full analysis
/dev/null && { [ -f "$(dirname "$FILE")/tsconfig.json" ] || [ -f "tsconfig.json" ]; }; then TYPE=$(npx tsc --noEmit "$FILE" 2>&1 | grep -E 'error TS' | head -3) || true [ -n "$TYPE" ] && ERRORS="${ERRORS}tsc: ${TYPE}\n" fi ;; ``` ### Technical Analysis The post-edit hook automatically invokes `npx tsc` whenever an edited TypeScript file and a qualifying `tsconfig.json` are found. The script does not verify that `tsc` comes from a pinned, project-local TypeScript dependency. Depending on the installed npm/npx version and configuration, `npx` can resolve and download a missing package from a configured package registry. This converts a post-edit diagnostic action into a potential remote package retrieval and execution channel. The selected package version and registry are not constrained by this Skill. The diagnostic operation only requires execution of an already installed, trusted compiler. Allowing implicit package installation exceeds that minimum requirement. ### Attack Path 1. A user opens or edits a repository containing a TypeScript file and `tsconfig.json`. 2. The repository does not contain a trusted project-local `tsc` executable, or the environment resolves packages through an attacker-influenced registry. 3. The post-edit hook executes `npx tsc --noEmit`. 4. `npx` attempts to resolve or download a package rather than failing closed. 5. Package installation or lifecycle logic executes with the privileges and environment of the Agent user. ### Impact Assessment Successful exploitation permits arbitrary code execution as the operating-system account running the Agent. That code may access all files, credentials, environment variables, and network resources available to that account. The script does not reques ...[truncated 144 chars]- Remediation
View remediation
&1 | grep -E 'error TS' | head -3) || true ``` - Alternatively, use an npm execution mode that explicitly prohibits downloading missing packages. - Resolve the project root first and verify that the selected executable is beneath the expected project-local `node_modules` directory. - Fail closed or skip diagnostics when the pinned compiler is unavailable; do not install dependencies from a post-edit hook. - Document that dependency installation must be a separate, user-approved operation. ]]>
