T09 · Insecure Skill Coding Practices
- Location
scripts/run.py:75- Finding
Caller-Controlled API Endpoint Exposes Credentials and Medical Input
- Content
View full analysis
Vulnerability Details
File Location:
scripts/run.py:75-83, 205, 258-266
Vulnerability Type: Unrestricted transmission of credentials and sensitive input to a caller-controlled endpoint
Risk Level: HighVulnerable 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)python p.add_argument("--api-url", default=DEFAULT_API_URL, help="OpenAI compatible endpoint URL")python out["answer"] = call_llm( api_url=args.api_url, model=args.model, appkey=args.appkey, system_prompt=args.system_prompt, user_prompt=user_prompt, temperature=float(args.temperature), timeout=int(args.timeout), )Technical Analysis
The
--api-urlargument is entirely caller-controlled and is passed directly tourllib.request.Request. The program does not require HTTPS, validate the destination hostname against an allowlist, or prevent redirects to an untrusted destination.Every request sends the supplied application key in the
Authorization: Bearerheader. Its JSON body also includes the system prompt and user-provided question. Because the Skill processes medical questions and may receive real patient information, this body can contain sensitive medical or personal data.Consequently, anyone who can influence the command-line arguments can direct the credential and question to an attacker-operated endpoint. A plain HTTP URL can additionally expose this information to network interception. The standard-library HTTP client may follow redirects, further weakening the assumption that the credential is sent only to the intended API.
Attack Path
- The attacker creates an HTTP service that records request headers and bodies.
- The attacker supplies or recommends a command using an endpoint such as:
bash
...[truncated 1391 chars]
- Remediation
View remediation
Remediation Suggestions
-
Restrict the destination
- Use a strict allowlist of approved HTTPS hostnames.
- Prefer removing
--api-urlin production if endpoint customization is unnecessary. - Parse the URL and reject unsupported schemes, embedded credentials, unexpected ports, and unapproved hosts.
-
Enforce secure transport
- Reject all non-HTTPS URLs.
- Retain normal TLS certificate and hostname verification.
- Consider certificate pinning where operationally appropriate.
-
Control redirects
- Disable automatic redirects for authenticated requests or validate every redirect target against the same scheme and hostname allowlist.
- Never forward the
Authorizationheader across an origin change.
-
Separate credentials by endpoint
- Do not send the default provider credential to a custom host.
- Require a separate, explicitly supplied credential for approved custom endpoints.
-
Protect medical data
- Warn users before transmitting content to a non-default service.
- Add input redaction or de-identification controls for patient-related information.
- Record destination approval without logging credentials or complete sensitive prompts.
-
Validate configuration before processing
- Reject unsafe endpoint configuration before reading sensitive input or constructing the authenticated request.
- Add tests covering HTTP URLs, unapproved hosts, redirects, user-info components, and unusual ports.
-
