T09 · Insecure Skill Coding Practices
- Location
scripts/yufluent_api.py:19- Finding
Configurable Plaintext API Endpoint Can Expose Credentials and Customer Data
- 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) except requests.RequestException as exc: raise YufluentApiError(f"Request failed: {exc}") from exc ``` ### Technical Analysis The client accepts `TOKENAPI_BASE_URL` without validating its scheme or destination. Although the default plaintext endpoint is loopback, the same URL normalization logic permits arbitrary remote HTTP endpoints. Every request includes `TOKENAPI_KEY` as a bearer credential. The JSON body may contain buyer messages, order numbers, tracking information, product details, and seller policy context. Consequently, setting ...[truncated 2146 chars]- Remediation
View remediation
