T09 · Insecure Skill Coding Practices
Error
- Location
- .env:1
- Finding
- Committed Wallet Private Key Enables Unauthorized Transaction Signing## Vulnerability Details **File Location**: `.env`, line 1 **Vulnerability Type**: Hardcoded cryptographic secret **Risk Level**: Critical ### Vulnerable Code ```dotenv PRIVATE_KEY="0x4083026c087523ea5fe156f3ec9351838041574de0547f5da150a6d1c80d246a" ``` The upload scripts directly consume this secret when creating the transaction signer: ```javascript const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider) ``` ### Technical Analysis A complete Ethereum wallet private key is stored in a project-level `.env` file. Files included in project archives, source-control history, CI artifacts, developer backups, or shared workspaces must be treated as accessible to anyone who can obtain the project. Possession of an Ethereum private key is sufficient to impersonate the wallet. No additional password, host access, or authorization is required to generate valid signatures. The public and encrypted upload scripts load the key through `dotenv` and use it to construct an `ethers.Wallet`, confirming that it is an operational signing credential rather than an inert example value. Because private keys cannot be made safe again by deleting the current file if they have already been distributed, the exposed wallet must be considered compromised. ### Attack Path 1. An attacker obtains a copy of the repository, archive, development workspace, CI artifact, or source-control history. 2. The attacker reads `.env` and extracts the wallet private key. 3. The attacker imports the key into an Ethereum-compatible wallet or uses `ethers.Wallet`. 4. The attacker queries the associated address and balances through a compatible RPC endpoint. 5. The attacker signs and broadcasts arbitrary transactions as that wallet. 6. Any funds, tokens, or protocol permissions controlled by the wallet can be used without the legitimate operator's consent. ### Impact Assessment The attacker obtains the full cryptographic identity and tran ...[truncated 467 chars]
- Remediation
- ## Remediation Suggestions 1. Immediately treat the exposed wallet as compromised and rotate to a newly generated key. 2. Transfer any assets and revoke protocol approvals associated with the exposed address. 3. Stop reusing the exposed key on every network and external service. 4. Remove `.env` from the repository and purge it from source-control history and published artifacts. 5. Add `.env` and related secret files to `.gitignore`. 6. Commit only an `.env.example` containing placeholders such as `PRIVATE_KEY=`. 7. Inject the key at runtime through a protected secret manager, CI secret facility, hardware wallet, or restricted environment variable. 8. Add secret scanning to pre-commit and CI workflows to reject wallet keys and similar credentials. 9. Validate that production deployments do not copy secret-bearing files into images, logs, backups, or build artifacts.
