T09 · Insecure Skill Coding Practices
- Location
- SYSTEMD_SETUP.md:53
- Finding
- Unnecessary Persistent Storage of the Wallet Private Key<![CDATA[ ## Vulnerability Details **File Locations**: - `SYSTEMD_SETUP.md:53-59` - `SYSTEMD_SETUP.md:344-368` - `CONFIGURATION.md:256-281` - `CONFIGURATION.md:602-612` - `README.md:198-210` - `polymarket_oracle.py:35-41` **Vulnerability Type**: Unnecessary collection and persistent plaintext storage of a wallet private key **Risk Level**: High ### Vulnerable Code and Configuration `SYSTEMD_SETUP.md:53-59` instructs users to place the wallet private key directly in a systemd unit: ```ini # Environment Variables - REPLACE WITH YOUR CREDENTIALS Environment="POLYMARKET_API_KEY=your_polymarket_api_key_here" Environment="POLYMARKET_SECRET=your_polymarket_secret_here" Environment="POLYMARKET_PASSPHRASE=your_polymarket_passphrase_here" Environment="WALLET_PRIVATE_KEY=your_wallet_private_key_here" Environment="TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here" Environment="TELEGRAM_CHAT_ID=your_telegram_chat_id_here" ``` `SYSTEMD_SETUP.md:344-368` also recommends persistently storing the key in a server-side environment file: ```bash # Create credentials file sudo mkdir -p /etc/polymarket-oracle sudo nano /etc/polymarket-oracle/credentials.env # Content: POLYMARKET_API_KEY=your_key POLYMARKET_SECRET=your_secret POLYMARKET_PASSPHRASE=your_passphrase WALLET_PRIVATE_KEY=your_private_key TELEGRAM_BOT_TOKEN=your_token TELEGRAM_CHAT_ID=your_id POLYMARKET_CAPITAL=10000 # Protect file sudo chmod 600 /etc/polymarket-oracle/credentials.env sudo chown root:root /etc/polymarket-oracle/credentials.env ``` The service is then configured to load this file: ```ini EnvironmentFile=/etc/polymarket-oracle/credentials.env ``` `CONFIGURATION.md:256-281` similarly instructs users to export the private key and make it persistent: ```bash # Polymarket credentials export POLYMARKET_API_KEY="your_api_key" export POLYMARKET_SECRET="your_secret" export POLYMARKET_PASSPHRASE="your_passphrase" export WALLET_PRIVATE_KEY="0x..." # Telegram (optional) export TELEGRAM_BOT_TOKEN="your_bot_toke ...[truncated 4383 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove all runtime use of the wallet private key: - Delete `WALLET_PRIVATE_KEY = os.getenv("WALLET_PRIVATE_KEY")` from `polymarket_oracle.py`. - Remove the key from `SKILL.md` runtime requirements. - Remove it from every README, shell, environment-file, and systemd example. 2. Generate Polymarket API credentials only on a trusted local machine: - Use the wallet key only during the one-time credential-generation process. - Do not copy the key to the server running the scanner. - Prefer a dedicated low-value wallet if a signing operation is unavoidable. 3. Store only revocable runtime credentials: - `POLYMARKET_API_KEY` - `POLYMARKET_SECRET` - `POLYMARKET_PASSPHRASE` - Optional Telegram credentials 4. Do not place secrets directly in a systemd unit. Use a dedicated secret store or, at minimum, a root-owned environment file with: - Ownership `root:root` - Mode `0600` - Exclusion from backups and source control - A documented credential-rotation process 5. Run the service as a dedicated unprivileged account rather than suggesting `root`: - Use a separate user with no interactive login. - Grant write access only to the required log directory. - Retain `NoNewPrivileges=true` and add further systemd sandboxing where compatible. 6. Revoke and rotate any credentials deployed according to the existing instructions. If a real wallet private key was stored on a server, migrate funds to a newly generated wallet because the private key itself cannot be safely rotated. ]]>
