T09 · Insecure Skill Coding Practices
- Location
feishu_tts.py:20- Finding
Unrestricted TTS Endpoint Override Can Disclose API Credentials and Message Content
- Content
View full analysis
Vulnerability Details
File Location:
feishu_tts.py:20andfeishu_tts.py:74-79
Vulnerability Type: Arbitrary network destination for sensitive data
Risk Level: MediumVulnerable Code
python VOLC_API_KEY = os.environ.get('VOLC_API_KEY') VOLC_TTS_URL = os.environ.get('VOLC_TTS_URL', 'https://openspeech.bytedance.com/api/v1/tts') VOICE_TYPE = os.environ.get('VOLC_VOICE_TYPE')python headers = { "x-api-key": api_key, "Content-Type": "application/json" } print(f"Generating voice for: {text}") response = requests.post(VOLC_TTS_URL, headers=headers, json=payload, timeout=60)Technical Analysis
The
VOLC_TTS_URLenvironment variable can replace the official Volcengine TTS endpoint with an arbitrary URL. The value is used directly byrequests.postwithout validating its scheme, hostname, port, or destination.The outbound request contains two sensitive values:
- The Volcengine API key in the
x-api-keyheader. - The complete user-supplied message text in the JSON request body.
The API key may originate from either
VOLC_API_KEYor the local~/.volcengine_keyfile. Consequently, an attacker who can influence the process environment could redirect a credential loaded from the local configuration file without needing to read that file directly.Sending the API key and message text to the official Volcengine service is necessary for the declared TTS functionality. Allowing an unrestricted and undocumented destination override is not necessary and exceeds the minimum network privileges required by the Skill.
Attack Path
- An attacker or compromised launcher gains the ability to define environment variables for the Skill process.
- The attacker sets
VOLC_TTS_URLto an HTTPS endpoint under their control. - A user invokes
feishu_tts.pywith text intended for speech synthesis. - The script retrieves the Volcengine API key from
VOLC_API_KEYor ...[truncated 820 chars]
- The Volcengine API key in the
- Remediation
View remediation
Remediation Suggestions
-
Remove the
VOLC_TTS_URLoverride if custom TTS endpoints are not a required feature, and use a constant official endpoint:python VOLC_TTS_URL = "https://openspeech.bytedance.com/api/v1/tts" -
If endpoint configurability is required, parse the URL and enforce an explicit allowlist:
- Require the
httpsscheme. - Require the exact approved hostname, such as
openspeech.bytedance.com. - Reject embedded credentials, unexpected ports, IP-literal hosts, fragments, and unapproved subdomains.
- Do not rely on suffix-only hostname checks.
- Require the
-
Disable automatic redirects for requests carrying credentials, or validate every redirect destination before following it:
python response = requests.post( VOLC_TTS_URL, headers=headers, json=payload, timeout=60, allow_redirects=False, ) -
Fail closed when endpoint validation fails and avoid sending either the API key or message text until validation is complete.
-
Document every supported network destination and configuration override so operators can assess data disclosure boundaries.
-
Use a narrowly scoped Volcengine credential restricted to only the required TTS operation, with quota limits, rotation procedures, and monitoring for anomalous usage.
-
