T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/create_shipment.py:66
- Finding
- Arbitrary API destination can expose shipment data and WMS credentials## Vulnerability Details **File Location**: `scripts/create_shipment.py:66-74`, `scripts/create_shipment.py:91-92`, and `scripts/create_shipment.py:106-107` **Vulnerability Type**: Unrestricted transmission of sensitive information to a user-controlled endpoint **Risk Level**: High ### Vulnerable Code ```python # Request headers headers = { "Content-Type": "application/json", "Authorization": f"Bearer {api_key}" } try: response = requests.post(api_url, json=payload, headers=headers, timeout=30) response.raise_for_status() return response.json() ``` ```python parser.add_argument("--api-url", default=WMS_API_URL, help="WMS API address") parser.add_argument("--api-key", default=WMS_API_KEY, help="WMS API key") ``` ```python api_url=args.api_url, api_key=args.api_key ``` ### Technical Analysis The script sends the recipient's name, telephone number, physical address, order details, remarks, and a Bearer credential to `api_url`. Creating a shipment legitimately requires sending this information to an authorized WMS service. However, `--api-url` permits callers or agent-generated commands to replace the documented WMS endpoint with an arbitrary destination. No scheme validation, hostname allowlist, trusted-origin check, or redirect policy is applied before the request. Consequently, a command that selects an attacker-controlled HTTPS server will transmit both the sensitive shipment payload and the `Authorization` header directly to that server. This exceeds least privilege because the declared functionality only requires communication with the configured WMS service, not arbitrary Internet hosts. The API key is also accepted through a command-line argument. On applicable systems, command-line values may be retained in shell history, process inspection output, job logs, or agent execution logs. ### Attack Path 1. An attacker influences a user, automation workflow, or agent-generate ...[truncated 1464 chars]
- Remediation
- ## Remediation Suggestions 1. Remove `--api-url` from normal runtime input and configure the WMS endpoint through an administrator-controlled configuration file. 2. If endpoint configurability is required, parse the URL and enforce: - HTTPS only; - an explicit allowlist of trusted hostnames; - the expected port and path prefix; - rejection of embedded credentials, fragments, IP literals, and malformed hosts. 3. Disable redirects with `allow_redirects=False`, or validate every redirect destination before transmitting sensitive content. 4. Do not accept API keys through command-line arguments. Load them from a protected environment variable, secret manager, or credential file with restrictive permissions. 5. Avoid logging credentials, complete recipient data, or raw request payloads. 6. Use a narrowly scoped WMS credential that can perform only the shipment operation required by this Skill, and rotate any credential that may have appeared in command history or execution logs. 7. Require explicit user confirmation showing the trusted destination hostname before transmitting recipient information.
