T09 · Insecure Skill Coding Practices
- Location
scripts/pronunciation-assess.sh:8- Finding
Azure Speech API Key Exposed in Process Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/pronunciation-assess.sh, lines 8-10 and 65-69
Vulnerability Type: Sensitive credential exposure through process arguments
Risk Level: MediumVulnerable 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
curlheader argument. The expanded header, including the secret, can therefore be present in the command-line metadata of the runningcurlprocess.Supplying the key through
AZURE_SPEECH_KEYinstead of argument 3 does not fully mitigate the issue. In either case, the shell expands${AZURE_KEY}before startingcurl, causing the resulting header value to be included incurl'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
- An authorized user invokes
pronunciation-assess.shwith a valid Azure Speech API key, either through argument 3 or theAZURE_SPEECH_KEYenvironment variable. - The script starts
curland placesOcp-Apim-Subscription-Key: <secret>in its argument vector. - 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.
- The inspecting process extracts the Azure subscription key from the header argument.
- The ...[truncated 689 chars]
- An authorized user invokes
- Remediation
View remediation
Remediation Suggestions
- Remove support for passing the Azure key as a positional command-line argument.
- Avoid expanding the credential into a
curlcommand-line header argument. - Supply the sensitive header through a protected curl configuration file or another mechanism that does not expose the value in process arguments.
- If a temporary configuration file is used:
- Create it with
mktemp. - Set permissions to
0600before writing the credential. - Store it only in a trusted local directory.
- Register an
EXIT,INT,TERM, andHUPtrap to remove it reliably. - Do not print its contents or include the key in error messages.
- Create it with
- Restrict the Azure key to the minimum required service and resource scope where supported.
- Rotate the existing key if the script has been used on systems where untrusted processes could inspect command-line metadata.
- Prefer short-lived Azure authentication credentials where the deployment environment supports them.
