T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/submit_nano_banana.sh:4
- Finding
- API Key Exposure Through Command-Line Arguments## Vulnerability Details **File Location**: `scripts/submit_nano_banana.sh`, lines 4–6 **Vulnerability Type**: API credential exposure through process arguments and shell history **Risk Level**: Medium ### Vulnerable Code ```sh api_key="${POYO_API_KEY:-${1:-}}" if [ -z "$api_key" ]; then echo "Usage: submit_nano_banana.sh [api_key] [payload.json]" >&2 echo "Or set POYO_API_KEY and pass [payload.json]. If no payload file is given, JSON is read from stdin." >&2 ``` ### Technical Analysis When `POYO_API_KEY` is unset, the script accepts the API key as its first positional command-line argument. Secrets supplied this way can be recorded in shell history, process-accounting systems, terminal logs, job telemetry, CI/CD logs, and command-line audit records. Depending on operating-system process visibility and timing, another local user may also read the argument from process metadata while the script is running. Although the script also supports the safer `POYO_API_KEY` environment variable, its usage instructions explicitly promote the insecure positional-argument option. ### Attack Path 1. A user runs the script as documented: ```sh scripts/submit_nano_banana.sh "$API_KEY" payload.json ``` 2. The API key becomes part of the command-line invocation. 3. The invocation is retained in shell history, operational telemetry, process accounting, or CI logs, or is observed through process inspection while running. 4. An attacker with access to that local metadata retrieves the key. 5. The attacker uses the credential to make unauthorized requests to the PoYo API. This path requires access to the affected host, its logs, or its command telemetry; the script does not independently transmit the key to an undeclared destination. ### Impact Assessment Successful exploitation exposes the user's PoYo API credential. An attacker may submit requests under the victim's account, consume paid quota, incur charges, or access other API functionality authorized to ...[truncated 162 chars]
- Remediation
- ## Remediation Suggestions 1. Remove positional command-line support for `POYO_API_KEY`. 2. Require the credential through `POYO_API_KEY` or a protected secret-management mechanism. 3. If interactive entry is needed, read the key without terminal echo rather than placing it in an argument: ```sh if [ -z "${POYO_API_KEY:-}" ]; then printf 'PoYo API key: ' >&2 stty -echo IFS= read -r POYO_API_KEY stty echo printf '\n' >&2 fi api_key="$POYO_API_KEY" ``` 4. For automation, inject the variable from a CI/CD secret store and configure log masking. 5. Change the interface so the only positional argument is the payload file: ```sh : "${POYO_API_KEY:?POYO_API_KEY must be set}" api_key="$POYO_API_KEY" payload="${1:-}" ``` 6. Update `SKILL.md` and the script's usage output to prohibit passing credentials on the command line. 7. Rotate any API key previously supplied as an argument if command history or execution logs may have been retained.
