T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/products_from_ticket_system.py:37
- Finding
- Ticket System signed requests can be redirected to an untrusted endpoint<![CDATA[ ## Vulnerability Details **File Location**: `scripts/products_from_ticket_system.py:37-47` and request execution at line 61 **Vulnerability Type**: Unvalidated destination for credentialed, signed requests **Risk Level**: High ### Vulnerable Code ```python access_key_id = get_env("ALICLOUD_ACCESS_KEY_ID") access_key_secret = get_env("ALICLOUD_ACCESS_KEY_SECRET") security_token = os.getenv("ALICLOUD_SECURITY_TOKEN") or os.getenv("ALIBABA_CLOUD_SECURITY_TOKEN") endpoint = get_env("TICKET_ENDPOINT") version = os.getenv("TICKET_VERSION", "2021-06-10") client = AcsClient(access_key_id, access_key_secret, "cn-hangzhou", security_token) request = CommonRequest() request.set_domain(endpoint) request.set_version(version) request.set_action_name("ListProducts") request.set_method("GET") ``` The request is subsequently transmitted without validating the destination: ```python response = client.do_action_with_exception(request) ``` ### Technical Analysis `TICKET_ENDPOINT` is accepted directly from the process environment and passed to `CommonRequest.set_domain()` without checking that it is an approved Alibaba Cloud hostname. The `AcsClient` signs the resulting request using the configured access-key credentials. An attacker who can influence environment configuration can redirect the signed request to an attacker-controlled server. Depending on the SDK authentication format, that server may receive the access-key identifier, request signature, timestamp, nonce, request parameters, and an optional STS security token. The code does not directly transmit the long-term access-key secret, but captured signed authorization material and temporary tokens remain sensitive. This behavior exceeds the minimum privilege required to query a known Alibaba Cloud Ticket System endpoint because arbitrary destinations do not need to receive credentialed requests. ### Attack Path 1. An attacker gains influence over deployment configuration, shell environment variables, ...[truncated 1135 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove arbitrary endpoint overrides when they are not operationally necessary. 2. Resolve the Ticket System endpoint from a fixed service and region mapping maintained by the application. 3. If endpoint customization is required: - Parse the value as a hostname rather than accepting an arbitrary URL. - Reject user information, paths, query strings, fragments, explicit ports, and IP literals. - Require an exact approved hostname or a carefully validated Alibaba Cloud suffix such as `.aliyuncs.com`. - Require HTTPS and reject redirects to non-approved origins. 4. Prefer short-lived STS credentials with permission limited to `ListProducts`. 5. Log the validated destination before execution without logging authorization headers, signatures, tokens, or secrets. 6. Add tests proving that attacker-controlled domains, deceptive suffixes, and absolute URLs are rejected. ]]>
