T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/wait_for_task.py:105
- Finding
- API Credential Exposed in URL Query Parameters<![CDATA[ ## Vulnerability Details **File Location**: `scripts/wait_for_task.py:105-110, 128-133` **Vulnerability Type**: Credential exposure through URL query strings **Risk Level**: High ### Vulnerable Code ```python payload = request_json( STATUS_ENDPOINT, {"api_key": api_key, "task_id": task_id}, api_key, request_timeout, ) ``` ```python return request_json( DOWNLOAD_ENDPOINT, {"api_key": api_key, "task_id": task_id, "type": "json"}, api_key, request_timeout, ) ``` The called function constructs the URL directly from these parameters: ```python def request_json(endpoint, params, api_key, timeout): url = endpoint + "?" + urllib.parse.urlencode(params) request = urllib.request.Request(url, method="GET") ``` ### Technical Analysis The API credential is included as the `api_key` query parameter in requests to the task-status and result-download endpoints. Although HTTPS protects the request in transit, URL query strings are routinely captured by reverse-proxy access logs, web server logs, application monitoring, exception telemetry, and debugging tools. The later response-body redaction: ```python if api_key: text = text.replace(api_key, "<redacted>") ``` does not protect the request URL and therefore does not mitigate this exposure. ### Attack Path 1. A user configures `DATAIFY_API_TOKEN`. 2. The task waiter polls the status endpoint or downloads a completed result. 3. The token is transmitted in a URL such as `...?api_key=<token>&task_id=<id>`. 4. Dataify infrastructure, a reverse proxy, monitoring system, or debugging tool records the complete URL. 5. A party with access to those records extracts the token. 6. The recovered credential is reused to consume account credits or access task results. ### Impact Assessment An exposed token may allow unauthorized use of the victim’s Dataify account, consumption of paid credits, and access to task status or downloaded results available to that credential. Exp ...[truncated 164 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove `api_key` from all URL query parameters. - Authenticate using an HTTP header: ```python request = urllib.request.Request( url, headers={"Authorization": "Bearer {}".format(api_key)}, method="GET", ) ``` - Update both task-status and download requests to use the header-based mechanism. - If the remote API only supports query-string authentication, use short-lived, task-scoped credentials and explicitly disable URL logging at every intermediary. - Add tests that assert the token never appears in constructed URLs, logs, exceptions, progress output, or resume instructions. ]]>
