T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/password-protect-pdf.py:193
- Finding
- Arbitrary API base URL permits disclosure of the PDF, password, and Bearer token## Vulnerability Details **File Location**: `scripts/password-protect-pdf.py:30, 57-64, 82-86, 193-197` **Vulnerability Type**: Unrestricted sensitive-data transmission endpoint **Risk Level**: High ### Vulnerable Code ```python DEFAULT_BASE_URL = "https://api.xss-cross-service-solutions.com/solutions/solutions" ``` ```python def create_job( base_url: str, api_key: str, pdf_path: str, password: str, timeout_s: int = 120, ) -> Dict[str, Any]: 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")} data = {"userPass": password} resp = requests.post(url, headers=headers, files=files, data=data, timeout=timeout_s) ``` ```python def get_job( base_url: str, api_key: str, job_id: Any, timeout_s: int = 30, ) -> Dict[str, Any]: 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 Uploading the PDF and its password to the documented Solutions API is explicitly declared by the Skill and is necessary for its remote-service design. However, the implementation allows the destination to be replaced through either the `SOLUTIONS_BASE_URL` environment variable or the `--base-url` argument. The replacement URL is not restricted to the documented service, validated against an approved hostname, or required to use HTTPS. The same Bearer token intended for the legitimate service is attached to requests sent to the replacement destination. The initial POST also contains the complete PDF and the password supplied for protecting it. This ...[truncated 1387 chars]
- Remediation
- ## Remediation Suggestions - Remove `--base-url` and `SOLUTIONS_BASE_URL` support if alternate service instances are not a strict functional requirement. - Hardcode the documented HTTPS origin and construct request paths from that trusted origin. - If endpoint configurability is required, parse the URL and enforce: - The `https` scheme. - An explicit allowlist of approved hostnames. - An expected port. - No embedded credentials. - No redirects to unapproved origins. - Configure requests not to forward authorization credentials across redirects. Validate the final response origin when redirects are permitted. - Use separate, non-production credentials for approved development endpoints. - Require explicit user confirmation before uploading a document to a non-default approved environment. - Document that the PDF and its password are transmitted to a third-party processor and clarify the service's retention and privacy expectations.
