T09 · Insecure Skill Coding Practices
- Location
scripts/scidraw_generate.py:192- Finding
Arbitrary API endpoint override can disclose the API credential and confidential prompts
- Content
View full analysis
Dict[str, Any]: headers = { "Accept": "application/json", "Authorization": f"Bearer {api_key}", "User-Agent": "SciDraw-Skill/1.0", } body = None if payload is not None: body = json.dumps(payload).encode("utf-8") headers["Content-Type"] = "application/json" ``` ```python api_base_url = os.getenv( "SCIDRAW_API_BASE_URL", DEFAULT_API_BASE_URL ).strip().rstrip("/") if not api_base_url.startswith(("https://", "http://")): die("SCIDRAW_API_BASE_URL must be an HTTP(S) URL.") prompt = read_prompt(args.prompt, args.prompt_file) out_path = Path(args.out).expanduser().resolve() request_payload = { "prompt": prompt, "aspect_ratio": args.aspect_ratio, "resolution": args.resolution, "count": args.count, } idempotency_key = f"scidraw-skill-{uuid.uuid4().hex}" started = time.monotonic() try: job = api_request( "POST", f"{api_base_url}/images/generations", api_key, payload=request_payload, extra_headers={ "Idempotency-Key": idempotency_key, "Prefer": "wait=30", }, ) ``` ### Technical Analysis The client obtains its API destination from `SCIDRAW_API_BASE_URL` and accepts any URL beginning with `http://` or `https://`. It does not validate the normalized hostname, port, or trust relationship with SciDraw. Every request made through `api_request()` attaches `SCIDRAW_API_KEY` as an `Authorization: Bearer` credential. Generation requests also transmit the complete prompt, which may contain unpublished re ...[truncated 1755 chars]- Remediation
View remediation
