T09 · Insecure Skill Coding Practices
- Location
scripts/yufluent_api.py:20- Finding
Bearer Token and Sensitive User Data Can Be Transmitted over Plaintext HTTP
- Content
View full analysis
str: base = (base_url or "").strip().rstrip("/") if not base: base = "http://localhost:8080/v1" if base.endswith("/v1"): return base return f"{base}/v1" ``` ```python def _auth_headers(api_key: str) -> dict[str, str]: return { "Authorization": f"Bearer {api_key}", "Accept": "application/json", } def _json_headers(api_key: str) -> dict[str, str]: return {**_auth_headers(api_key), "Content-Type": "application/json"} ``` ```python def _post_json( url: str, *, api_key: str, body: dict[str, Any] | None = None, timeout: float, ) -> requests.Response: kwargs: dict[str, Any] = { "headers": _json_headers(api_key) if body is not None else _auth_headers(api_key), "timeout": timeout, } if body is not None: kwargs["json"] = body return requests.post(url, **kwargs) ``` ```python root = base_url or os.getenv("TOKENAPI_BASE_URL", "") url = skill_run_url(root, skill_id) try: resp = _post_json(url, api_key=key, body=payload, timeout=timeout) ``` ### Technical Analysis The API URL normalization logic accepts arbitrary schemes and hosts without requiring HTTPS. The default HTTP endpoint is a loopback service, which can be appropriate for local development, but the same logic also permits a remotely hosted `http://` URL through `TOKENAPI_BASE_URL` or the `base_url` argument. Every request attaches `TOKENAPI_KEY` as a bearer credential and sends the full compliance payload. Depending on the command-line options, that payload can contain product descriptions, mat ...[truncated 1944 chars]- Remediation
View remediation
