T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/animate_anyone.py:38
- Finding
- Authentication credentials can be redirected to attacker-controlled endpoints<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/animate_anyone.py:38, 124-130, 138-176` - `scripts/live_portrait.py:41, 48-63, 96-102` - `scripts/image_to_video.py:32, 37-51, 73-79` - `scripts/portrait_animate.py:15, 19-27, 43-50` - `scripts/text_to_image.py:22, 29-44` - `scripts/avatar_video.py:37-40` **Vulnerability Type**: Unvalidated authentication endpoint override **Risk Level**: High ### Vulnerable Code Representative DashScope implementation: ```python BASE_URL = os.getenv( "DASHSCOPE_BASE_URL", "https://dashscope.aliyuncs.com", ) def _headers(async_mode: bool = False) -> dict: key = os.environ.get("DASHSCOPE_API_KEY") if not key: raise RuntimeError("DASHSCOPE_API_KEY not set") h = { "Authorization": f"Bearer {key}", "Content-Type": "application/json", } if async_mode: h["X-DashScope-Async"] = "enable" return h r = requests.post( f"{BASE_URL}/api/v1/services/aigc/image2video/aa-detect", headers=_headers(async_mode=False), json={"model": "animate-anyone-detect-gen2", "input": {"image_url": image_url}}, timeout=60, ) ``` Representative OSS implementation: ```python auth = oss2.Auth( os.environ["ALIBABA_CLOUD_ACCESS_KEY_ID"], os.environ["ALIBABA_CLOUD_ACCESS_KEY_SECRET"], ) bucket_name = os.environ["OSS_BUCKET"] endpoint = os.environ.get( "OSS_ENDPOINT", "oss-cn-beijing.aliyuncs.com", ) endpoint = endpoint.replace("https://", "").replace("http://", "").rstrip("/") bucket = oss2.Bucket(auth, f"https://{endpoint}", bucket_name) bucket.put_object_from_file(key, local_path) url = bucket.sign_url("GET", key, expires) ``` LingMou has an equivalent configurable endpoint: ```python config = open_api_models.Config( access_key_id=os.environ["ALIBABA_CLOUD_ACCESS_KEY_ID"], access_key_secret=os.environ["ALIBABA_CLOUD_ACCESS_KEY_SECRET"], endpoint=os.environ.get( "LINGMOU_ENDPOINT", "lingmou.cn-beijing.aliyuncs.c ...[truncated 2820 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove production endpoint overrides unless they are strictly required. 2. Validate every configured endpoint before constructing an authenticated client: - Require HTTPS. - Reject embedded user information. - Reject fragments and unexpected query strings. - Reject unexpected ports. - Compare the parsed hostname against an explicit allowlist. 3. Use exact hostname or label-aware suffix checks. Do not use a naïve check such as `host.endswith("aliyuncs.com")` without also verifying the domain boundary. 4. Maintain separate allowlists for each service, for example: - DashScope: approved regional DashScope hosts. - OSS: the expected bucket and regional endpoint. - LingMou: approved regional LingMou hosts. 5. Disable redirects for authenticated API calls, or validate every redirect destination before forwarding authentication headers. 6. Use separate, least-privilege credentials for OSS, DashScope, and LingMou. Do not reuse a broadly privileged Alibaba access key. 7. Update `SECURITY.md` to accurately disclose endpoint configurability and its trust assumptions. 8. Add tests confirming rejection of attacker-controlled domains, suffix-confusion domains, HTTP URLs, userinfo URLs, and unexpected ports. ]]>
