T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/pronunciation-assess.sh:8
- Finding
- Azure Speech API Key Exposed in Process Command-Line Arguments## Vulnerability Details **File Location**: `scripts/pronunciation-assess.sh`, lines 8-10 and 65-69 **Vulnerability Type**: Sensitive credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```bash AZURE_KEY="${3:-$AZURE_SPEECH_KEY}" AZURE_REGION="${4:-$AZURE_SPEECH_REGION}" ``` ```bash RESULT=$(curl -s -X POST \ "${ENDPOINT}?language=en-US&format=detailed" \ -H "Ocp-Apim-Subscription-Key: ${AZURE_KEY}" \ -H "Content-Type: ${CONTENT_TYPE}" \ -H "Pronunciation-Assessment: ${PRON_CONFIG}" \ ``` ### Technical Analysis The script accepts an Azure Speech API key as positional argument 3 and expands the key directly into a `curl` header argument. The expanded header, including the secret, can therefore be present in the command-line metadata of the running `curl` process. Supplying the key through `AZURE_SPEECH_KEY` instead of argument 3 does not fully mitigate the issue. In either case, the shell expands `${AZURE_KEY}` before starting `curl`, causing the resulting header value to be included in `curl`'s process arguments. Depending on the operating system's process-inspection restrictions, local users, processes running under the same account, monitoring agents, diagnostic utilities, or a compromised local process may be able to inspect this metadata. The exposure exists for the duration of each Azure request. ### Attack Path 1. An authorized user invokes `pronunciation-assess.sh` with a valid Azure Speech API key, either through argument 3 or the `AZURE_SPEECH_KEY` environment variable. 2. The script starts `curl` and places `Ocp-Apim-Subscription-Key: <secret>` in its argument vector. 3. While the request is active, a local process with permission to inspect the target process reads its command-line metadata, such as through process-monitoring facilities. 4. The inspecting process extracts the Azure subscription key from the header argument. 5. The ...[truncated 689 chars]
- Remediation
- ## Remediation Suggestions 1. Remove support for passing the Azure key as a positional command-line argument. 2. Avoid expanding the credential into a `curl` command-line header argument. 3. Supply the sensitive header through a protected curl configuration file or another mechanism that does not expose the value in process arguments. 4. If a temporary configuration file is used: - Create it with `mktemp`. - Set permissions to `0600` before writing the credential. - Store it only in a trusted local directory. - Register an `EXIT`, `INT`, `TERM`, and `HUP` trap to remove it reliably. - Do not print its contents or include the key in error messages. 5. Restrict the Azure key to the minimum required service and resource scope where supported. 6. Rotate the existing key if the script has been used on systems where untrusted processes could inspect command-line metadata. 7. Prefer short-lived Azure authentication credentials where the deployment environment supports them.
