T09 · Insecure Skill Coding Practices
- Location
scripts/_const.py:14- Finding
Authenticated Requests Can Be Redirected to an Arbitrary Destination
- Content
View full analysis
Vulnerability Details
File Location:
scripts/_const.py:14-17; request use occurs atscripts/_http.py:89-107andscripts/_http.py:148-164
Vulnerability Type: Unrestricted authenticated API destination
Risk Level: MediumVulnerable Code:
python # scripts/_const.py:14-17 BASE_URL = os.environ.get( "DISTRIBUTE_BASE_URL", "https://skills-gateway.1688.com", )python # scripts/_http.py:89-107 url = f"{BASE_URL}{path}" body_str = json.dumps(body or {}, ensure_ascii=False) headers = get_auth_headers("POST", path, body_str) if not headers: raise AuthError("AK 未配置") headers["Content-Type"] = "application/json; charset=utf-8" try: resp = requests.post( url, headers=headers, data=body_str.encode("utf-8"), timeout=timeout ) resp.raise_for_status() except requests.exceptions.HTTPError as e: _handle_http_error(e)python # scripts/_http.py:148-164 url = f"{BASE_URL}{path}" body_str = json.dumps(body or {}, ensure_ascii=False) headers = get_auth_headers("POST", path, body_str) if not headers: raise AuthError("AK 未配置") headers["Content-Type"] = "application/json; charset=utf-8" try: resp = requests.post( url, headers=headers, data=body_str.encode("utf-8"), timeout=timeout ) resp.raise_for_status() except requests.exceptions.HTTPError as e: _handle_http_error(e)Technical Analysis
The complete API origin is controlled by the
DISTRIBUTE_BASE_URLenvironment variable. The value is used without validating its scheme, hostname, port, or trust relationship with the expected 1688 gateway.Before each request, the Skill generates authentication headers containing the access-key identifier, timestamp, nonce, request-body digest, and HMAC signature. These headers are then sent to the configured destination. The acces ...[truncated 2175 chars]
- Remediation
View remediation
Remediation Suggestions
- Require the production API origin to match an explicit allowlist, such as
https://skills-gateway.1688.com. - Reject all non-HTTPS schemes, embedded credentials, fragments, unexpected ports, and malformed URLs.
- Permit alternate destinations only through an explicit development or test mode that is disabled by default.
- Construct endpoints with validated URL parsing and joining rather than direct string concatenation.
- Disable redirects for authenticated requests with
allow_redirects=False, or manually follow redirects only after validating every destination against the same allowlist. - Ensure deployment tooling prevents untrusted users or child processes from modifying
DISTRIBUTE_BASE_URL. - Enforce strict server-side timestamp expiration, nonce uniqueness, and replay prevention for all signed operations.
- Avoid including sensitive business data in requests to any development endpoint unless the operator explicitly confirms the destination.
- Require the production API origin to match an explicit allowlist, such as
