T09 · Insecure Skill Coding Practices
- Location
scripts/speak.sh:143- Finding
Azure Speech API Key Exfiltration Through Unvalidated Region Endpoint
- Content
View full analysis
- Remediation
View remediation
&2 exit 1 ;; esac ``` If maintaining an allowlist is impractical, enforce a strict region syntax that excludes URL delimiters and other authority-changing characters: ```bash if [[ ! "${AZURE_SPEECH_REGION}" =~ ^[a-z0-9]+$ ]]; then echo "Invalid AZURE_SPEECH_REGION" >&2 exit 1 fi ``` Additional hardening should include: 1. Constructing endpoints from a trusted mapping of supported region names to fixed Azure hostnames. 2. Rejecting values containing `/`, `\`, `:`, `@`, dots, whitespace, percent encoding, or control characters. 3. Verifying that the final hostname exactly matches an expected Azure Speech hostname before invoking `curl`. 4. Avoiding user-controlled endpoint overrides when requests carry subscription keys. 5. Rotating the Azure Speech key if the script has already been run with an untrusted region value. 6. Adding tests that confirm malicious values such as `attacker.example/path`, `eastus@attacker.example`, and values containing whitespace are rejected before any network request occurs. ]]>
