T09 · Insecure Skill Coding Practices
- Location
SKILL.md:296- Finding
Unrestricted API Base URL Can Exfiltrate the Service Credential
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:296, 310, 337-347
Vulnerability Type: Unvalidated destination for authenticated network requests
Risk Level: MediumVulnerable Code
python Base URL overridable via REPUTATION_BASE_URL (default https://api.reputation.ru). BASE_URL = os.environ.get("REPUTATION_BASE_URL", "https://api.reputation.ru").rstrip("/") def _request(method, path, *, params=None, body=None, expect="json", timeout=60): if not API_KEY: raise CourtApiError("REPUTATION_API_KEY is not set") url = BASE_URL + path if params: url += "?" + urllib.parse.urlencode(params) headers = {"Authorization": API_KEY} data = None if body is not None: data = json.dumps(body).encode("utf-8") headers["Content-Type"] = "application/json" req = urllib.request.Request(url, data=data, headers=headers, method=method) try: with urllib.request.urlopen(req, timeout=timeout) as resp:Technical Analysis
The bundled REST client accepts
REPUTATION_BASE_URLdirectly from the process environment without validating its scheme, hostname, port, or user-information component._request()then attachesREPUTATION_API_KEYto every request through theAuthorizationheader.Consequently, anyone able to influence the environment used to launch the client can redirect authenticated requests to an arbitrary server. The override also permits plaintext HTTP, exposing the credential and request content to network interception. Because
urllib.request.urlopen()supports redirects, authorization behavior across redirects should also be constrained explicitly rather than relying on implicit client behavior.Sending the API key to the legitimate
https://api.reputation.ruendpoint is necessary for the Skill’s declared functionality. Sending it to an unrestricted environment-selected destination exceeds that minimum requirement.Attack Path
- An attacker, compromised wrapper ...[truncated 1373 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the
REPUTATION_BASE_URLoverride if custom deployments are not a required feature. - If the override is required, parse it with
urllib.parse.urlsplit()and enforce:- The
httpsscheme. - An explicit allowlist of trusted hostnames, such as
api.reputation.ru. - No embedded username or password.
- No unexpected port.
- An empty or explicitly approved base path.
- The
- Construct URLs using validated components rather than direct string concatenation.
- Disable automatic redirects or implement a redirect handler that rejects cross-origin redirects. Never forward
Authorizationto a different origin. - Fail closed with a clear error when endpoint validation fails.
- Keep the key in an environment variable or credential store and never print it in errors or diagnostic output.
- Add tests confirming that HTTP URLs, unapproved hosts, user-information components, unexpected ports, and cross-origin redirects are rejected.
- Remove the
