T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/convert.sh:17
- Finding
- API Token Exposed Through Curl Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/convert.sh`, lines 17-34; `scripts/credits.sh`, lines 9-12 **Vulnerability Type**: Bearer token exposure through process command-line arguments **Risk Level**: Medium ### Vulnerable Code `scripts/convert.sh`, lines 17-23 and 34: ```bash CURL_ARGS=( --silent --fail --show-error -X POST -H "Authorization: Bearer ${MDA_API_TOKEN:?MDA_API_TOKEN is not set}" -F "file=@${FILE_PATH}" ) RESPONSE=$(curl "${CURL_ARGS[@]}" "https://markdownanything.com/api/v1/convert") ``` `scripts/credits.sh`, lines 9-12: ```bash RESPONSE=$(curl --silent --fail --show-error \ -H "Authorization: Bearer ${MDA_API_TOKEN:?MDA_API_TOKEN is not set}" \ "https://markdownanything.com/api/v1/credits") ``` ### Technical Analysis Both scripts expand `MDA_API_TOKEN` directly into a `curl` command-line argument. The shell therefore passes the complete `Authorization: Bearer ...` header as part of the process argument vector. While the request is active, locally authorized users or processes may be able to inspect the argument vector through process-monitoring facilities such as `ps` or `/proc/<pid>/cmdline`. The exact visibility depends on operating-system configuration, user boundaries, container isolation, and process-inspection restrictions. TLS protects the token while it is transmitted over the network, but it does not prevent this local command-line disclosure. ### Attack Path 1. An attacker obtains the ability to inspect processes belonging to the user running the skill, or otherwise has access permitted by the host's process-inspection policy. 2. The victim invokes `scripts/convert.sh` or `scripts/credits.sh`. 3. The attacker continuously monitors process argument vectors while waiting for a `curl` process. 4. The attacker captures the argument containing `Authorization: Bearer <token>`. 5. The attacker extracts and replays the token against the Markdown Anything API. 6. The attacker uses whateve ...[truncated 780 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Avoid placing the bearer token directly in `curl` command-line arguments. 1. Supply the sensitive header through a protected `curl` configuration stream or file descriptor instead of `-H` in the visible argument vector. 2. If a temporary configuration file is necessary: - Create it with `mktemp`. - Set restrictive permissions with `chmod 600`. - Register a `trap` to delete it on normal exit, errors, and signals. - Store it only in a trusted local directory. 3. Prevent tracing and accidental logging around secret handling. 4. Run the scripts under a dedicated least-privileged account and restrict cross-process inspection where supported. 5. Ensure API tokens have minimum required permissions, short validity periods where possible, and a documented rotation and revocation procedure. 6. Rotate the token if there is reason to believe it has already been exposed. One possible hardening pattern is to provide configuration through standard input: ```bash RESPONSE=$( printf 'header = "Authorization: Bearer %s"\n' "$MDA_API_TOKEN" | curl --config - \ --silent --fail --show-error \ -X POST \ -F "file=@${FILE_PATH}" \ "https://markdownanything.com/api/v1/convert" ) ``` Before adoption, verify on every supported platform that the configuration contents do not appear in process listings, logs, or diagnostic output. ]]>
