T09 · Insecure Skill Coding Practices
- Location
scripts/robot_cmd.py:35- Finding
Credentials Can Be Redirected to an Untrusted or Cleartext API Endpoint
- Content
View full analysis
dict: return { "base_url": _env("JOYIN_API_BASE", "https://api-open-test.joyin-ai.com").rstrip("/"), "auth_key": _env("JOYIN_AUTH_KEY"), "device_sn": _env("JOYIN_DEVICE_SN"), "device_type_id": _env("JOYIN_DEVICE_TYPE_ID", "3"), } def _headers(cfg: dict) -> dict: return { "Content-Type": "application/json", "Authorization": cfg["auth_key"], "Device-Sn": cfg["device_sn"], "Device-Type-Id": str(cfg["device_type_id"]), } ``` The command-line override is applied without validation: ```python if args.base_url: cfg["base_url"] = args.base_url.rstrip("/") ``` ### Technical Analysis The API destination can be supplied through `JOYIN_API_BASE` or the global `--base-url` option. The implementation does not require HTTPS, validate the hostname, reject embedded credentials, or restrict the destination to an approved JoyIn domain. All API requests use `_headers()`, which attaches the JoyIn authorization key, device serial number, and device type identifier. Consequently, any command can disclose these values to the configured host. If an attacker can influence the environment or command arguments, authenticated requests can be redirected to an attacker-controlled server. A cleartext `http://` endpoint would also expose credentials and request contents to network observers. This behavior exceeds the minimum privilege necessary for robot control because the official functionality only requires communication with a trusted JoyIn API endpoint. There is no evidence that the default JoyIn URL is malicious, but the missing destination and transport controls create an exploitable credential-disclosure path. ### Attac ...[truncated 1108 chars]- Remediation
View remediation
