T09 · Insecure Skill Coding Practices
- Location
scripts/key_manager.sh:29- Finding
Arbitrary JavaScript Execution Through Unescaped Secret Input
- Content
View full analysis
"$TEMP_SCRIPT" << EOF const SecureKeyVault = require('$WORKSPACE_DIR/scripts/key_vault_simple.js'); const vault = new SecureKeyVault('$WORKSPACE_DIR'); async function addSecret() { try { await vault.initialize(); await vault.setSecret('$SECRET_NAME', '$SECRET_VALUE', {type: 'manual'}); console.log('Secret added successfully'); } catch (err) { console.error('Error:', err.message); process.exit(1); } } addSecret(); EOF node "$TEMP_SCRIPT" rm "$TEMP_SCRIPT" ``` The same unsafe source-code generation pattern is used for the secret name in the `get` operation at `scripts/key_manager.sh:61-86` and for migrated credentials at `scripts/key_manager.sh:139-167`. ### Technical Analysis `SECRET_NAME` and `SECRET_VALUE` are inserted directly into JavaScript single-quoted string literals without escaping. The generated file is then passed to `node`, meaning these values are treated as JavaScript source code rather than data. Shell quoting around the here-document does not make the resulting JavaScript safe. A value containing a quote, closing parenthesis, and additional statements can terminate the intended string literal and inject arbitrary JavaScript. For example, a malicious secret value shaped like the following can break out of the `setSecret` call: ```text '); require('child_process').execSync('id'); // ``` The resulting temporary JavaScript contains attacker-controlled executable statements. ### Attack Path 1. An attacker invokes or causes a user or aut ...[truncated 1281 chars]- Remediation
View remediation
