T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/set-token.cjs:9
- Finding
- Bearer Token Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/set-token.cjs:9-16`; invoked as documented in `SKILL.md:21-24` **Vulnerability Type**: Secret exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```javascript const token = process.argv[2]; if (!token) { console.error('Usage: node set-token.js <token>'); process.exit(1); } const envPath = path.join(__dirname, '..', '.env'); fs.writeFileSync(envPath, `ELASTOLINK_TOKEN=${token}\n`); ``` The documented workflow explicitly places the token in the command: ```markdown 1. Run `node D:\workspace\demo\elastolink\scripts\get-token.cjs` 2. If the output is `NO_TOKEN`, ask the user to enter a token and save it: - User enters a token in the format `sk-xxx` - Run `node D:\workspace\demo\elastolink\scripts\set-token.cjs <token>` ``` ### Technical Analysis The script receives the bearer token through `process.argv`. Command-line arguments may be exposed through operating-system process inspection, shell history, terminal telemetry, agent execution traces, audit systems, and command logging. This is especially relevant in an AI-agent workflow because the agent must interpolate the user-provided secret into a command string. That command may consequently be retained independently of the destination `.env` file. ### Attack Path 1. A user provides an Elastolink bearer token to the agent. 2. The agent invokes `set-token.cjs` with the token embedded in the command line. 3. The command or process arguments are captured by shell history, process-monitoring tools, agent logs, or execution telemetry. 4. A local user or log reader obtains the exposed token. 5. The attacker submits the token as an `Authorization: Bearer` credential to the configured MCP endpoint. 6. Subject to the token's server-side privileges, the attacker can access meeting-service operations available to that credential. ### Impact Assessment Successful exploitation discloses the Elastolink bearer token. An ...[truncated 330 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not accept secrets through command-line arguments. - Read the token from masked interactive input or standard input without echoing it. - Prefer an operating-system credential manager or secret-management service over a plaintext project file. - Ensure agent execution logs and telemetry redact authentication credentials. - Update `SKILL.md` so the documented workflow never interpolates a token into a command. - If standard input is used, pass it directly to the process rather than constructing a shell command containing the secret. ]]>
