T09 · Insecure Skill Coding Practices
- Location
SKILL.md:65- Finding
Stripe API Key Exposed Through Process Arguments
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 65–71
Vulnerability Type: Sensitive credential exposure through command-line arguments and insufficient local file-permission controls
Risk Level: MediumVulnerable Code
bash ### 3. Fetch Script Template ```bash #!/bin/bash # Requires: STRIPE_API_KEY in environment curl -s -u "$STRIPE_API_KEY:" \ https://api.stripe.com/v1/balance \ | jq '.' > ~/dashboard/stripe/data.jsontext ### Technical Analysis The user is correctly instructed to supply the Stripe API key through an environment variable rather than store it directly in a file. However, `curl -u "$STRIPE_API_KEY:"` causes the shell to expand the secret into the `curl` process argument list. Depending on operating-system process-visibility restrictions and local monitoring configuration, another local user, privileged process, diagnostic utility, audit service, or telemetry agent may be able to capture the expanded command-line argument while `curl` is running. This undermines the intended protection provided by environment-based credential handling. The fetched Stripe response is also written directly to `~/dashboard/stripe/data.json` without setting a restrictive `umask` or explicit file permissions. Its accessibility therefore depends on the user's existing directory permissions and `umask`. Because Stripe balance data is financially sensitive, relying on ambient defaults is not sufficient hardening. Sending the credential to `https://api.stripe.com/v1/balance` is otherwise consistent with the declared functionality and is not, by itself, unauthorized exfiltration: Stripe must receive an authentication credential to service the user-requested API call. ### Attack Path 1. The user exports a valid `STRIPE_API_KEY` and runs the generated fetch script. 2. The shell expands `$STRIPE_API_KEY` into the argument supplied to `curl -u`. 3. While the process is active, a local obse ...[truncated 1115 chars]- Remediation
View remediation
Remediation Suggestions
- Avoid expanding the API key directly into command-line arguments. Use a protected, temporary curl configuration or another authentication mechanism that does not expose the secret in the process argument list.
- Create temporary credential material with mode
0600, remove it immediately after use with a shelltrap, and ensure it is never committed or logged. - Prefer a narrowly scoped, read-only Stripe restricted key that grants access only to the data required by the dashboard.
- Add
umask 077at the beginning of generated fetch scripts. - Create dashboard directories with mode
0700and data files with mode0600. - Write API responses to a securely created temporary file, validate that the request and JSON transformation succeeded, and atomically rename the file to
data.json. This prevents both unsafe permissions and partial output. - Disable shell tracing around credential handling and ensure generated scripts never print secrets in errors or diagnostics.
