T09 · Insecure Skill Coding Practices
- Location
scripts/make-pdf-safe.py:187- Finding
Arbitrary API Endpoint Override Exposes PDF Content and Bearer Credentials
- Content
View full analysis
Dict[str, str]: return {"Authorization": f"Bearer {api_key}"} ``` ```python url = base_url.rstrip("/") + CREATE_PATH headers = make_headers(api_key) with open(pdf_path, "rb") as f: files = {"file": (os.path.basename(pdf_path), f, "application/pdf")} resp = requests.post(url, headers=headers, files=files, timeout=timeout_s) ``` ```python url = base_url.rstrip("/") + f"/api/{job_id}" headers = make_headers(api_key) resp = requests.get(url, headers=headers, timeout=timeout_s) ``` ```python ap.add_argument( "--base-url", default=os.getenv("SOLUTIONS_BASE_URL", DEFAULT_BASE_URL), help="Base URL override", ) ``` ### Technical Analysis The script permits the API destination to be overridden through either the `--base-url` argument or the `SOLUTIONS_BASE_URL` environment variable. It does not validate the URL scheme, hostname, port, or path before attaching the Bearer credential and uploading the complete PDF. The declared functionality only requires communication with the documented Solutions API host. Allowing an unrestricted destination therefore exceeds the minimum network privilege necessary for the Skill. An attacker who can influence command arguments, environment variables, a wrapper script, or deployment configuration can redirect requests to an attacker-controlled endpoint. That endpoint receives: - The complete PDF document in a multipart upload. - The Solutions API Bearer credential in the `Authorization` header. - Subsequen ...[truncated 1579 chars]- Remediation
View remediation
