T09 · Insecure Skill Coding Practices
- Location
scripts/realtime_tts_demo.py:91- Finding
User-Controlled API Endpoint Can Receive Credentials and Synthesis Content
- Content
View full analysis
dict[str, Any]: dashscope.base_http_api_url = base_url try: stream = dashscope.MultiModalConversation.call( model=REALTIME_MODEL, api_key=os.getenv("DASHSCOPE_API_KEY"), text=text, voice=voice, instruction=instruction, language_type=language_type, stream=True, ) ``` The fallback path has the same behavior: ```python def _fallback_generate( text: str, voice: str, instruction: str | None, language_type: str, base_url: str, output: Path, ) -> dict[str, Any]: dashscope.base_http_api_url = base_url response = dashscope.MultiModalConversation.call( model=FALLBACK_MODEL, api_key=os.getenv("DASHSCOPE_API_KEY"), text=text, voice=voice, instruction=instruction, language_type=language_type, stream=False, ) ``` The destination is controlled through a command-line argument: ```python parser.add_argument( "--base-url", default="https://dashscope.aliyuncs.com/api/v1", ) ``` ### Technical Analysis The command-line `--base-url` value is assigned directly to the DashScope SDK's global API URL without validating its scheme, hostname, port, or ownership. The script then explicitly supplies `DASHSCOPE_API_KEY` to the SDK request together with the text, voice, language, and synthesis instruction. Although sending an API key to Alibaba Cloud is necessary for the declared TTS functionality, allowing an arbitrary destination exceeds the minimum privilege and trus ...[truncated 1386 chars]- Remediation
View remediation
