T09 · Insecure Skill Coding Practices
Warning
- Location
- setup.sh:8
- Finding
- API Key Exposed Through Shell History and Process Arguments<![CDATA[ ## Vulnerability Details **File Location**: `setup.sh:8-9` and documented usage at `SKILL.md:23` **Vulnerability Type**: Sensitive credential exposure through command-line arguments **Risk Level**: Medium ### Vulnerable Code ```bash --add-key) if [ -n "${2:-}" ]; then MUAPI_API_KEY="$2" muapi auth configure --api-key "$2" else muapi auth configure fi ;; ``` The documented invocation also instructs users to place the credential directly on the command line: ```bash bash setup.sh --add-key "YOUR_MUAPI_KEY" ``` ### Technical Analysis The API key is accepted as a positional command-line argument and forwarded to the `muapi` executable through `--api-key "$2"`. Quoting prevents shell command injection, but it does not protect the confidentiality of the value. The key may be exposed through: - The user's shell-history file, because the documented command contains the key. - Process inspection while `muapi auth configure` is running, subject to the operating system's process-visibility controls. - Process monitoring, diagnostic collection, audit logging, or endpoint-management software that records command arguments. - CI/CD or terminal logs that capture the invoked command. Assigning the same value to `MUAPI_API_KEY` does not mitigate the issue because the key remains duplicated in the child process's argument vector. ### Attack Path 1. A user follows `SKILL.md` and runs `bash setup.sh --add-key "SECRET_KEY"`. 2. The command containing the key may be written to shell history or captured in terminal or automation logs. 3. The script starts `muapi auth configure --api-key "SECRET_KEY"`, temporarily exposing the key in the process argument list. 4. A local user or monitoring component with sufficient process visibility, or anyone who later gains access to the relevant history or logs, retrieves the key. 5. The attacker submits the recovered credential to MuAPI and performs operations permitted by the associated account. ...[truncated 513 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not accept API keys as command-line arguments in the recommended workflow. 2. Read the key interactively without terminal echo, for example with `read -r -s`, and clear the shell variable after use. 3. Pass the credential to `muapi` through standard input, a protected credential file, an operating-system secret store, or another supported mechanism that does not expose it in process arguments. 4. If `muapi` only supports `--api-key`, request or implement a stdin-based configuration option. Until then, clearly warn users about process and history exposure. 5. Update `SKILL.md` so its primary example invokes an interactive configuration flow, such as: ```bash bash setup.sh --add-key ``` 6. Ensure any credential file created by the downstream CLI has restrictive permissions, such as owner-only access. 7. Advise affected users to remove exposed commands from shell and automation logs and rotate any API key previously entered through the documented command. ]]>
