T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/generate_validator_key.py:53
- Finding
- Validator Private Keys Are Disclosed Through Standard Output<![CDATA[ ## Vulnerability Details **File Location**: `scripts/generate_validator_key.py:53-64`; additional occurrence in `SKILL.md:87-97` **Vulnerability Type**: Plaintext disclosure of cryptographic private keys **Risk Level**: High ### Vulnerable Code ```python private_key, public_key = generate_keypair() address = pubkey_to_address(public_key) pubkey_b64 = pubkey_to_base64(public_key) if args.genesis_entry: entry = { "address": address, "pub_key": { "type": "tendermint/PubKeyEd25519", "value": pubkey_b64 }, "power": args.power, "name": args.name } print("Genesis validator entry:") print(json.dumps(entry, indent=2)) print(f"\nPrivate key (keep secret!): {private_key}") else: print(f"Private key: {private_key}") ``` The documentation also instructs users to generate and print a private key: ```python from nacl.signing import SigningKey import secrets sk = SigningKey(secrets.token_bytes(32)) print(f'Private key: {sk.encode().hex()}') print(f'Public key: {sk.verify_key.encode().hex()}') ``` ### Technical Analysis The key-generation script always writes the newly generated Ed25519 private key to standard output. The `--genesis-entry` option does not suppress this disclosure; it prints the private key after the public genesis entry. In an AI-agent or automated execution environment, standard output can be captured in conversation transcripts, command logs, CI/CD logs, telemetry, terminal history, or other retained execution records. Labeling the output as secret does not protect it from those capture mechanisms. The Base64 conversion at `scripts/generate_validator_key.py:32-34` is not itself a vulnerability. It encodes only the public key in the representation required by the CometBFT genesis format and performs no transmission. The security issue is the separate plaintext private-key output. ### Attack Path 1. A user or agent invokes `scripts/generate_validator_key ...[truncated 914 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not print private keys by default. 2. Write the private key directly to a user-selected file opened with restrictive permissions such as `0600`. 3. Print only non-sensitive information, including the public key, validator address, genesis entry, and protected key-file path. 4. If plaintext display is retained as an exceptional feature, require an explicit option such as `--show-private-key` and display a clear warning and interactive confirmation. 5. Avoid returning private keys through agent-visible tool output. 6. Document secure backup, access-control, rotation, and deletion procedures for validator keys. 7. Consider integrating an encrypted keystore, hardware security module, or dedicated secret-management system. ]]>
