T09 · Insecure Skill Coding Practices
- Location
scripts/milaex_client.py:35- Finding
API Credential Exfiltration Through Unrestricted Base URL Override
- Content
View full analysis
MilaexConfig: base_url = os.getenv("MILAEX_BASE_URL", "https://api.milaex.com").rstrip("/") api_key = os.getenv("MILAEX_API_KEY", "").strip() if not api_key: raise SystemExit( "Missing MILAEX_API_KEY env var. " "Set it to your Milaex API key (x-api-key header)." ) return MilaexConfig(base_url=base_url, api_key=api_key) def request_json( path: str, params: Optional[Dict[str, Any]] = None, *, print_rate_headers: bool = True, timeout_s: int = 30, ) -> Any: cfg = load_config() url = f"{cfg.base_url}{path}" headers = { "x-api-key": cfg.api_key, "accept": "application/json", } try: resp = requests.get(url, headers=headers, params=params or {}, timeout=timeout_s) ``` ### Technical Analysis The client obtains its destination from the undocumented `MILAEX_BASE_URL` environment variable and sends the value of `MILAEX_API_KEY` to that destination in the `x-api-key` header. The destination is not restricted to the official Milaex API hostname, and the code does not require HTTPS. Consequently, any process or configuration source capable of influencing the skill's environment can redirect authenticated requests to an attacker-controlled endpoint. Python Requests verifies TLS certificates for HTTPS by default, but that protection does not prevent requests to an attacker-owned, validly certified hostname. The implementation also permits an `http://` URL, which could expose the key to network interception. This issue does not independently grant an attacker control of the environment. Exploitation requires influence over `MILAEX_BASE_URL` or the configuration mechanism that injects environment variables. ...[truncated 1352 chars]- Remediation
View remediation
