T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:37
- Finding
- Nostr Private Key Exposed Through Chat and Process Arguments<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 37-41 and 103-123 **Vulnerability Type**: Sensitive credential exposure through conversation history, shell expansion, and command-line arguments **Risk Level**: High ### Vulnerable Code ```markdown ### 3. Give Your Bot Your nsec Your **nsec** is your Nostr private key. Find it in RUNSTR under **Settings > Keys** (or your Nostr key manager). **Tell your bot:** "Here's my RUNSTR nsec: nsec1..." Your bot uses the nsec to decrypt your encrypted fitness backup from Nostr. The nsec is never stored, logged, or transmitted — it's used only for the decryption step in your current session. ``` ```bash content=$(nak req -k 30078 -a $hex_pk -t d=runstr-workout-backup -l 1 \ wss://relay.damus.io wss://nos.lol | jq -r '.content') # Decrypt (NIP-44 self-decryption: user to own pubkey) decrypted=$(echo "$content" | nak encrypt --sec $hex_sk $hex_pk --decrypt) ``` ```javascript // /tmp/decrypt-runstr.mjs — run with: node /tmp/decrypt-runstr.mjs <hex_sk> '<content>' import { gunzipSync } from 'zlib'; import NDK, { NDKPrivateKeySigner } from '@nostr-dev-kit/ndk'; const signer = new NDKPrivateKeySigner(process.argv[2]); const user = await signer.user(); const decrypted = await signer.decrypt(user, process.argv[3]); try { console.log(gunzipSync(Buffer.from(decrypted, 'base64')).toString()); } catch { console.log(decrypted); } ``` ### Technical Analysis The skill directs the user to disclose a complete Nostr private key directly to the agent. This places the credential in the conversation context, where it may be retained in session history, telemetry, diagnostics, or platform logs. The decoded key is subsequently expanded into a shell command and, in the Node.js fallback, supplied explicitly through `process.argv`. Command-line arguments can be visible to local process-inspection tools and may be captured by shell history, process accounting, monitoring software, crash reports, or diagnostic ...[truncated 1597 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not ask users to enter an `nsec` into a chat conversation. 2. Integrate with a local Nostr signer or key manager that performs decryption without exposing private-key material to the agent. 3. Use a dedicated fitness-only Nostr identity to limit the consequences of compromise. 4. If direct key use is unavoidable, obtain it through a protected secret prompt or file descriptor rather than command-line arguments. 5. Never pass the key through `process.argv`, shell interpolation, environment variables retained by process supervisors, or temporary files. 6. Quote all non-secret shell variables defensively and prevent command tracing while secret-bearing operations execute. 7. Redact credentials from errors, logs, telemetry, and command transcripts. 8. Clear in-memory secret buffers where supported and ensure decrypted temporary data is deleted securely. 9. Replace the unconditional privacy assertion with an accurate disclosure of the platform’s session-retention and logging behavior. ]]>
