T09 · Insecure Skill Coding Practices
- Location
SKILL.md:18- Finding
Untrusted npm Lifecycle Scripts May Execute During Package-Size Analysis
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 18 and 57
Vulnerability Type: Unsafe execution of package lifecycle scripts
Risk Level: HighVulnerable Code
markdown - Local package publishing footprint: run `npm pack --dry-run --json`.markdown - `pack --repo <path>`: Run `npm pack --json --dry-run` and report packed tarball, unpacked size, file count, and largest included files.Technical Analysis
The skill directs the agent to execute
npm pack --dry-runagainst a user-supplied repository. Despite the--dry-runoption, npm packaging can invoke package lifecycle scripts, including repository-controlledprepack,prepare, andpostpackcommands.Consequently, the packaging measurement crosses from passive file inspection into execution of code supplied by the repository being audited. No instruction requires
--ignore-scripts, explicit user confirmation, isolation, restricted credentials, network controls, or a sandbox. An attacker can therefore place an arbitrary shell command in a lifecycle script and wait for the package-size workflow to invoke it.The absent referenced helper script cannot be evaluated to determine whether it adds mitigations. The documented direct command itself remains unsafe when used on an untrusted repository.
Attack Path
- An attacker prepares or modifies a repository containing a
package.json. - The attacker adds a malicious lifecycle entry, such as a
prepackorpreparescript. - A user asks the agent to audit the repository's npm publishing footprint or run the broad package-size audit.
- Following
SKILL.md, the agent runsnpm pack --json --dry-runin that repository. - npm invokes the attacker-controlled lifecycle script.
- The script executes with the operating-system privileges and environment available to the agent process.
Impact Assessment
Successful exploitation permits arbitrary command e ...[truncated 719 chars]
- An attacker prepares or modifies a repository containing a
- Remediation
View remediation
Remediation Suggestions
-
Disable lifecycle scripts for package inspection:
sh npm pack --dry-run --json --ignore-scripts -
Ensure the referenced helper always passes
--ignore-scripts; do not rely solely on documentation or caller behavior. -
Treat repositories being audited as untrusted input and run npm operations inside an isolated sandbox or disposable container.
-
Restrict the sandbox to the target repository, use a read-only filesystem where practical, and deny access to host credentials and unrelated files.
-
Disable outbound network access unless it is essential to the requested analysis.
-
Remove npm, cloud, source-control, and SSH credentials from the command environment.
-
If lifecycle execution is explicitly required for an accurate package measurement, disclose that project code will run and obtain user confirmation before proceeding.
-
Consider implementing a passive packaging-footprint estimator based on npm inclusion rules and filesystem metadata when executing npm is unnecessary.
-
