T09 · Insecure Skill Coding Practices
- Location
scripts/openmandate.py:37- Finding
Unvalidated API Base URL Can Disclose the OpenMandate Bearer Credential
- Content
View full analysis
str: return os.environ.get(BASE_URL_ENV, DEFAULT_BASE_URL).rstrip("/") def _die(message: str) -> None: print(f"Error: {message}", file=sys.stderr) sys.exit(1) def _request(method: str, path: str, params: dict | None = None) -> dict: """Make an HTTP request to the OpenMandate API and return parsed JSON.""" base = _get_base_url() url = f"{base}{path}" if params: query = urllib.parse.urlencode({key: value for key, value in params.items() if value is not None}) if query: url = f"{url}?{query}" req = urllib.request.Request(url, method=method) req.add_header("Authorization", f"Bearer {_get_api_key()}") req.add_header("Content-Type", "application/json") req.add_header("Accept", "application/json") req.add_header("User-Agent", USER_AGENT) ``` ### Technical Analysis The helper obtains the request origin directly from the configurable `OPENMANDATE_BASE_URL` environment variable. It does not validate the URL scheme, hostname, port, path, or user-information component before attaching the secret from `OPENMANDATE_API_KEY` as a bearer credential. Consequently, the authorization header is not restricted to the legitimate `https://api.openmandate.ai` origin. A manipulated configuration can direct an authenticated request to an attacker-controlled HTTP or HTTPS endpoint. Allowing plain HTTP also permits interception of the credential by a network-positioned attacker. The HTTP client additionally relies on default redirect handling without explicitly enforcing a same-origin redirect policy. Security-sensitive authorization headers should never be forwarded to a different origin during redirects. ### Attack Path 1. An attacker obtains th ...[truncated 1653 chars]- Remediation
View remediation
