T09 · Insecure Skill Coding Practices
- Location
scripts/remove-metadata-from-pdf.py:60- Finding
Unrestricted API Endpoint Override Can Exfiltrate PDF Documents and Bearer Credentials
- Content
View full analysis
Dict[str, Any]: url = base_url.rstrip("/") + CREATE_PATH headers = make_headers(api_key) # multipart/form-data with multiple PDFs under the SAME key: "files" files: List[Tuple[str, Tuple[str, Any, str]]] = [] opened = [] try: for p in pdf_paths: f = open(p, "rb") opened.append(f) files.append(("files", (os.path.basename(p), f, "application/pdf"))) resp = requests.post(url, headers=headers, files=files, timeout=timeout_s) ``` The destination is obtained from an unrestricted command-line argument or environment variable: ```python ap.add_argument( "--base-url", default=os.getenv("SOLUTIONS_BASE_URL", DEFAULT_BASE_URL), help="Base URL override", ) ``` ### Technical Analysis The Skill is declared to upload PDF files to a specific Solutions API endpoint. However, its implementation permits `base_url` to be replaced with an arbitrary value through either `--base-url` or `SOLUTIONS_BASE_URL`. The selected URL is used without validating its scheme or hostname. The script subsequently transmits two sensitive assets to that destination: 1. Every user-selected PDF file, as multipart form data. 2. The Solutions API key, in the `Authorization: Bearer` header. This exceeds the minimum privileges required for the declared functionality. Production operation requires access only to the documented Solutions API host, not permission to disclose credentials and documents to an arbitrary network destination. The absence of HTTPS enforcement also permits a caller to select a plaintext HTTP e ...[truncated 1805 chars]- Remediation
View remediation
