T09 · Insecure Skill Coding Practices
Warning
- Location
- package.json:14
- Finding
- Recursive npm Install Lifecycle Can Cause Resource Exhaustion## Vulnerability Details **File Location**: `package.json:14-16` **Vulnerability Type**: Recursive package-manager lifecycle execution **Risk Level**: Medium **Vulnerable Code**: ```json "scripts": { "install": "npm install" }, ``` ### Technical Analysis npm automatically executes the `install` lifecycle script during package installation. This project defines that lifecycle script as another invocation of `npm install`. Consequently, the initial installation can start a child npm process, which processes the same package and can invoke the same lifecycle script again. This creates an unbounded recursive installation chain rather than performing a finite setup operation. The behavior is especially hazardous in automated environments where installation is performed without interactive supervision and where process, memory, or execution-time limits are not tightly configured. ### Attack Path 1. A user or CI job follows the documented installation process and runs `npm install`. 2. npm resolves the dependencies and reaches the package's `install` lifecycle stage. 3. The lifecycle script launches another `npm install` process. 4. The child npm process processes the same lifecycle configuration. 5. Additional npm processes may continue to be created until the installation fails or the operating system, container, or CI runner exhausts a resource limit. No external attacker input is required. Triggering the documented installation operation is sufficient. ### Impact Assessment This issue does not grant additional privileges. Every child process runs with the same operating-system privileges as the user or service account that initiated npm. Potential consequences include: - CPU, memory, process-table, or disk exhaustion. - Denial of service on developer workstations or shared CI runners. - Installation timeouts and failed deployments. - Creation of orphaned or lingering npm processes. - Consumption ...[truncated 142 chars]
- Remediation
- ## Remediation Suggestions 1. Remove the recursive lifecycle script entirely: ```json "scripts": {} ``` 2. If explicit setup is required, implement it as a finite script under a non-lifecycle command: ```json "scripts": { "setup": "node scripts/setup.js" } ``` 3. Ensure setup scripts perform only bounded, idempotent operations and never invoke `npm install` recursively. 4. Update `SKILL.md` to document the corrected installation process. 5. Add a CI installation test with process and execution-time limits to detect recursive lifecycle behavior.
