T09 · Insecure Skill Coding Practices
- Location
scripts/run.py:87- Finding
Unrestricted API Endpoint Override Exposes Credentials and Sensitive Prompts
- Content
View full analysis
Vulnerability Details
File Location:
scripts/run.py, lines 87-101, 222, and 271-279
Vulnerability Type: Unrestricted transmission of credentials and sensitive data to a user-controlled endpoint
Risk Level: MediumVulnerable Code
python req = Request( api_url, data=json.dumps(payload, ensure_ascii=False).encode("utf-8"), headers={ "Content-Type": "application/json", "Authorization": f"Bearer {appkey}", }, ) resp = urlopen(req, timeout=timeout) body = json.loads(resp.read().decode("utf-8"))python p.add_argument("--api-url", default=DEFAULT_API_URL, help="OpenAI-compatible API endpoint")python out["answer"] = call_llm( api_url=args.api_url, model=args.model, appkey=args.appkey, system_prompt=system_prompt_for(task_key, args.system_prompt), user_prompt=user_prompt, temperature=float(args.temperature), timeout=int(args.timeout), )Technical Analysis
The
--api-urlcommand-line argument is passed directly tourlopenwithout validating its scheme or destination. The request always includes the supplied application key in theAuthorizationheader and the user's mental-health question in the JSON body.Consequently, any actor able to influence the script arguments can redirect the request to an attacker-controlled server. The implementation does not require HTTPS, enforce an approved-host allowlist, or prevent production credentials from being attached when a custom endpoint is selected.
Because this skill processes potentially sensitive medical and mental-health information, disclosure of the request body can have privacy and regulatory consequences beyond ordinary prompt leakage.
Attack Path
- A deployment or automation layer supplies a valid application key through
--appkey. - An attacker gains control over, or injects into, the configurable
--api-urlargument. 3 ...[truncated 1476 chars]
- A deployment or automation layer supplies a valid application key through
- Remediation
View remediation
Remediation Suggestions
-
Enforce HTTPS
- Parse the endpoint with
urllib.parse.urlsplit. - Reject every scheme except
https. - Reject URLs containing embedded user information or malformed hostnames.
- Parse the endpoint with
-
Allowlist trusted destinations
- Permit only the documented API hostname by default.
- If custom providers are required, use an administrator-managed allowlist rather than accepting arbitrary runtime URLs.
- Validate the normalized hostname and port, not a string prefix.
-
Separate credentials by endpoint
- Never send the production medical-model key to a custom endpoint.
- Require a separate credential explicitly configured for each approved provider.
- Consider disabling
--api-urlentirely in production deployments.
-
Control redirects
- Disable automatic redirects or validate every redirect target before following it.
- Do not forward authorization headers to a different origin.
-
Restrict internal and local destinations
- Resolve the destination and reject loopback, link-local, private, multicast, and otherwise prohibited address ranges unless explicitly required.
- Revalidate after DNS resolution and when processing redirects to reduce server-side request forgery risk.
-
Protect sensitive inputs
- Warn operators that questions may contain protected health information.
- Minimize transmitted data and avoid logging credentials or raw health-related prompts.
- Add automated tests confirming that unapproved hosts and plaintext HTTP endpoints are rejected.
-
