T09 · Insecure Skill Coding Practices
- Location
deploy-nft.js:502- Finding
Wallet Private Key Can Be Exposed Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
deploy-nft.js, lines 502-503
Vulnerability Type: Plaintext credential exposure through process arguments
Risk Level: HighVulnerable Code:
js const privateKey = getArg('private-key') || process.env.PRIVATE_KEY; if (!privateKey) { console.error('Error: set PRIVATE_KEY env or use --private-key'); process.exit(1); }The command-line interface explicitly documents this option at line 492:
js --private-key <key> Wallet private key (or set PRIVATE_KEY env)Technical Analysis
The application accepts a raw wallet private key through the
--private-keycommand-line option. Command-line arguments may be exposed through:- Process inspection utilities such as
psor/proc/<pid>/cmdline - Shell command history
- Process monitoring and endpoint telemetry
- CI/CD job logs
- Debugging and crash-reporting systems
Any local user or monitoring process with permission to inspect the deployment process may recover the key while the command is running. The key may remain accessible afterward if the complete command is retained in shell history or logs.
Although using the
PRIVATE_KEYenvironment variable avoids direct command-line exposure, environment variables can also be exposed through process inspection or diagnostic collection. An encrypted keystore or external signer is safer.Attack Path
- A user starts a deployment using:
bash node deploy-nft.js --private-key 0xSECRET... --generate-svg 10 --name "Example" --symbol "EX" - The complete command is recorded in shell history or exposed in the process argument list.
- A local attacker, monitoring agent, or log reader obtains the argument value.
- The attacker imports the recovered private key into another wallet.
- The attacker signs arbitrary transactions as the victim and can transfer assets or exercise contract privileges controlled by that wallet. ...[truncated 390 chars]
- Process inspection utilities such as
- Remediation
View remediation
Remediation Suggestions
- Remove support for the
--private-keycommand-line option. - Prefer an external wallet, hardware wallet, remote signer, or encrypted JSON keystore.
- If direct key entry remains necessary, read it from an interactive hidden prompt that does not echo or retain the value.
- Avoid printing, logging, serializing, or including the key in error objects.
- Clear references to sensitive key material as soon as practical, recognizing that JavaScript does not guarantee secure memory erasure.
- Warn users not to place secrets in shell history, source files,
.envfiles committed to version control, or CI job definitions. - Where environment variables must be supported, load them through a protected secret manager with restricted process and log access.
- Remove support for the
