T09 · Insecure Skill Coding Practices
- Location
scripts/osd_config.py:25- Finding
Unrestricted API Endpoint Can Receive Device Tokens and Authentication Metadata
- Content
View full analysis
Vulnerability Details
File Location:
scripts/osd_config.py, lines 25-26, 50-51, 73, 91-92, and 114
Vulnerability Type: Unrestricted credential-bearing network destination
Risk Level: HighVulnerable Code
python # API base address (switchable through an environment variable) JF_ENDPOINT = os.getenv("JF_ENDPOINT", "api-cn.jftechws.com") JF_BASE_URL = f"https://{JF_ENDPOINT}/gwp/v3"python def get_osd_config(device_token: str, uuid: str, app_key: str, app_secret: str, move_card: int, config_type: str = "single", channel: int = 0) -> Dict[str, Any]: """ Get OSD configuration API: POST /gwp/v3/rtc/device/getconfig/{deviceToken} """ url = f"{JF_BASE_URL}/rtc/device/getconfig/{device_token}" headers = get_headers(uuid, app_key, app_secret, move_card) name_map = { "single": "AVEnc.VideoWidget", "multi": "AVEnc.VideoOSD" } body = { "Name": name_map.get(config_type, "AVEnc.VideoWidget") } if channel is not None: body["Channel"] = str(channel) response = requests.post(url, headers=headers, json=body, timeout=30)python def set_osd_config(device_token: str, uuid: str, app_key: str, app_secret: str, move_card: int, config: Dict[str, Any], config_type: str = "single", channel: int = 0) -> Dict[str, Any]: """ Set OSD configuration API: POST /gwp/v3/rtc/device/setconfig/{deviceToken} """ url = f"{JF_BASE_URL}/rtc/device/setconfig/{device_token}" headers = get_headers(uuid, app_key, app_secret, move_card) name_map = { "single": "AVEnc.VideoWidget", "multi": "AVEnc.VideoOSD" } body = { "Name": name_map.get(config_type, "AVEnc.VideoWidget") } if config_ty ...[truncated 2937 chars]- Remediation
View remediation
Remediation Suggestions
- Replace the unrestricted hostname with an enumerated region option such as
CN,AS,EU, orNA. - Map each region internally to one of the four documented API hosts.
- If
JF_ENDPOINTmust remain configurable, parse it as a hostname and enforce an exact allowlist:api-cn.jftechws.comapi-as.jftechws.comapi-eu.jftechws.comapi-na.jftechws.com
- Reject values containing a scheme, path, query string, fragment, user information, unexpected port, trailing-dot variant, or unapproved Unicode hostname.
- Disable automatic redirects with
allow_redirects=False. If redirects are operationally necessary, validate every redirect target against the same exact allowlist before resending sensitive data. - Avoid placing access tokens in URL paths if the upstream API supports an authorization header or another protected request field.
- Use short-lived, narrowly scoped device tokens and rotate any token suspected of having been sent to an unauthorized endpoint.
- Add automated tests confirming that arbitrary hosts, alternate ports, malformed hostnames, and external redirects are rejected.
- Replace the unrestricted hostname with an enumerated region option such as
