T09 · Insecure Skill Coding Practices
- Location
scripts/animate_anyone.py:44- Finding
Configurable DashScope Base URL Can Expose Bearer Credentials and Submitted Content
- Content
View full analysis
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", "User-Agent": USER_AGENT, } if async_mode: h["X-DashScope-Async"] = "enable" return h def wait_task(task_id: str, interval: int = 10, max_wait: int = 1800) -> dict: """Poll until task SUCCEEDED/FAILED, return full output dict.""" url = f"{BASE_URL}/api/v1/tasks/{task_id}" start = time.time() while time.time() - start < max_wait: r = requests.get(url, headers=_headers(), timeout=60) ``` Authenticated submission from the same file: ```python 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, ) ``` The same design is used by the other listed DashScope scripts. For example, `scripts/text_to_image.py` contains: ```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 = { "Authorizatio ...[truncated 2436 chars]- Remediation
View remediation
