T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/setup_agent.py:17
- Finding
- Wallet Seed Exposed Through Process Arguments and Plaintext Output## Vulnerability Details **File Location**: `scripts/setup_agent.py:17-37` **Vulnerability Type**: Plaintext exposure of wallet seed material **Risk Level**: High ### Vulnerable Code ```python if len(sys.argv) < 2: print("Usage: python3 setup_agent.py <agent-seed-phrase>") print("Example: python3 setup_agent.py 'my-cool-agent-v1'") sys.exit(1) seed_phrase = sys.argv[1] try: from hypha_sdk import SeedManager except ImportError: print("hypha-sdk not installed. Run: pip install hypha-sdk") sys.exit(1) sm = SeedManager.from_string(seed_phrase) print("=" * 50) print(" HYPHA Agent Identity") print("=" * 50) print(f" Seed Phrase: {seed_phrase}") print(f" Node ID: {sm.node_id_hex}") print(f" Wallet: {sm.wallet_address}") print(f" Full Node ID: {sm.node_id.hex()}") print("=" * 50) print() print("Add to your agent config:") print(f' agent = Agent(seed="{seed_phrase}")') ``` ### Technical Analysis The script accepts the agent seed as a command-line argument and subsequently prints it twice in plaintext. Command-line secrets can be exposed through shell history, process inspection facilities, terminal recording, CI job metadata, debugging systems, and command auditing. Printing the seed additionally exposes it to terminal scrollback and collected stdout logs. According to `references/network.md:39-44`, the same seed is used to derive the P2P node identity and the EVM wallet private key: ```text A single 32-byte seed derives: 1. P2P Node ID 2. DHT Location 3. EVM Wallet — secp256k1 private key ``` Consequently, this value is not merely an agent name or configuration identifier. It is wallet key material whose disclosure permits deterministic reconstruction of the wallet private key. The usage example also encourages a human-readable value such as `my-cool-agent-v1`. This may have insufficient entropy and could be vulnerable to offline d ...[truncated 1651 chars]
- Remediation
- ## Remediation Suggestions 1. Do not accept wallet seeds through command-line arguments. Read an existing secret using `getpass.getpass()` or retrieve it from a protected operating-system keystore. 2. Never print the seed, private key, or configuration statements containing the seed. 3. Generate seeds with a cryptographically secure random number generator rather than encouraging human-readable phrases. 4. Store wallet material in an encrypted keystore with restrictive file permissions and explicit access controls. 5. Print only non-sensitive public identifiers, such as the wallet address and public node ID. 6. Add warnings preventing users from placing seeds in shell history, environment diagnostics, source files, or logs. 7. Redact secrets from exception messages and operational telemetry. 8. Treat any seed previously processed by the current script as potentially exposed. Migrate funds to a newly generated wallet and replace the associated P2P identity. 9. Correct the script documentation so it accurately states whether a seed is generated or imported. A safer interactive pattern would be: ```python from getpass import getpass seed_phrase = getpass("Enter agent seed: ") sm = SeedManager.from_string(seed_phrase) print(f"Node ID: {sm.node_id_hex}") print(f"Wallet: {sm.wallet_address}") ``` For new identities, secure random generation and encrypted storage should be preferred over manually entered phrases.
