T09 · Insecure Skill Coding Practices
- Location
scripts/generate_video.py:31- Finding
Credentials and User-Selected Local Media Can Be Transmitted to an Untrusted or Plaintext Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_video.py, lines 31-39, 151-152, and 235-250
Vulnerability Type: Unrestricted sensitive-data transmission destination
Risk Level: HighVulnerable Code
python def build_submit_url(base: str) -> str: base = base.strip().rstrip("/") if not base: raise SystemExit("Missing VOLCENGINE_ENDPOINT / ARK_BASE_URL / OPENAI_BASE_URL") if base.endswith("/contents/generations/tasks"): return base if base.endswith("/api/v3"): return base + "/contents/generations/tasks" return base + "/api/v3/contents/generations/tasks"python parser.add_argument("--endpoint", default=getenv("VOLCENGINE_VIDEO_ENDPOINT", "VOLCENGINE_ENDPOINT", "ARK_BASE_URL", "OPENAI_BASE_URL")) parser.add_argument("--api-key", default=getenv("VOLCENGINE_API_KEY", "ARK_API_KEY", "OPENAI_API_KEY"))python def make_headers(api_key: str) -> Dict[str, str]: return { "Content-Type": "application/json", "Authorization": f"Bearer {api_key}", } def submit_task(args: argparse.Namespace, payload: Dict[str, Any]) -> Dict[str, Any]: req = urllib.request.Request( build_submit_url(args.endpoint), data=json.dumps(payload).encode("utf-8"), headers=make_headers(args.api_key), method="POST", ) return request_json(req, min(args.timeout, 120))Local files included through
--imageor--videoare encoded and placed in that outbound request:python def local_file_to_data_url(path_str: str) -> str: path = pathlib.Path(path_str).expanduser().resolve() if not path.exists(): raise SystemExit(f"Local file not found: {path}") mime = mimetypes.guess_type(str(path))[0] or "application/octet-stream" encoded = base64.b64encode(path.read_bytes()).decode("ascii") return f"data:{mime};base64,{encoded}"Te
...[truncated 2604 chars]
- Remediation
View remediation
Remediation Suggestions
- Require
https://for all remote API endpoints and reject plaintext HTTP. - Default directly to the documented Volcengine endpoint rather than relying on broad provider fallbacks.
- Allow only approved Volcengine or ARK hostnames by default.
- If custom compatible endpoints are required, place them behind an explicit option such as
--allow-custom-endpointand present a warning that credentials and media will be transmitted to that host. - Remove the undocumented
OPENAI_BASE_URLandOPENAI_API_KEYfallbacks, or require explicit provider selection and validate that the credential source matches the selected endpoint. - Resolve and validate the final destination after redirects and reject redirects to a different or unapproved origin.
- Clearly display the destination hostname and the categories of data being uploaded before transmitting local media.
- Avoid accepting API keys through command-line arguments where process listings or shell history may expose them; prefer a protected credential store or narrowly scoped environment variable.
- Recommend short-lived, least-privilege API credentials with restricted quota.
- Require
