T03 · Remote Payload Retrieval and Execution
Error
- Location
- scripts/analyze.sh:47
- Finding
- Unpinned npm Package Is Downloaded and Executed with Access to a Wallet Private Key## Vulnerability Details **File Location**: `scripts/analyze.sh`, lines 25 and 47 **Vulnerability Type**: Unpinned runtime dependency and remote code execution through `npx` **Risk Level**: High ### Vulnerable Code ```bash if [ -n "$PRIVATE_KEY" ]; then export X402_PRIVATE_KEY="$PRIVATE_KEY" break fi ``` ```bash # Execute the market analysis npx -y @itzannetos/x402-tools-claude alpha-finder "$QUERY" ``` ### Technical Analysis The script exports a cryptocurrency wallet private key into its environment and subsequently invokes an npm package through `npx -y`. No exact package version, lockfile, integrity hash, or locally reviewed package source is provided. Consequently, `npx` can retrieve and execute whichever package version the npm registry resolves at execution time. The `-y` option suppresses the normal installation confirmation. The downloaded package inherits the script's environment, including `X402_PRIVATE_KEY`, and executes with the operating-system privileges of the user running the skill. This creates both a remote-payload and software-supply-chain trust boundary. Although the audited repository does not contain direct key-exfiltration code, a compromised package release, npm maintainer account, transitive dependency, or registry resolution could alter the effective payload after this skill has been reviewed. ### Attack Path 1. An attacker compromises the npm package, its maintainer account, a transitive dependency, or the applicable package-resolution path. 2. The attacker publishes code that reads `X402_PRIVATE_KEY`, signs unauthorized transactions, transmits the key, or executes arbitrary local commands. 3. A user invokes `scripts/analyze.sh` with a market query. 4. The script reads and exports the wallet private key. 5. `npx -y` downloads and executes the attacker-controlled package version without interactive confirmation. 6. The package inherits the wallet key and the invoking use ...[truncated 823 chars]
- Remediation
- ## Remediation Suggestions 1. Pin the dependency to an exact, reviewed version rather than relying on the registry's current resolution: ```bash npx --yes --package '@itzannetos/x402-tools-claude@EXACT_VERSION' \ x402-tools-claude alpha-finder "$QUERY" ``` Verify the package's actual executable name before adopting this example. 2. Commit a package manifest and lockfile, and install dependencies using a reproducible command such as `npm ci`. 3. Verify dependency integrity and provenance. Review the pinned package and its transitive dependencies before exposing any financial secret to them. 4. Prefer vendoring or locally installing reviewed source instead of downloading executable code during every invocation. 5. Do not provide a general-purpose or high-value wallet private key to third-party package code. 6. Use a dedicated, low-balance wallet with only the funds required for expected request fees. 7. Prefer an audited local signing service or hardware-backed signer that approves narrowly scoped transactions without disclosing the raw private key. 8. Execute the dependency in a restricted environment with minimal filesystem access, a sanitized environment, and limited network access where operationally possible. 9. Document the package version and re-audit all dependency updates before deployment.
