T09 · Insecure Skill Coding Practices
- Location
scripts/gameltbook_api.py:13- Finding
Authentication Token Can Be Disclosed to an Arbitrary Destination
- Content
View full analysis
Vulnerability Details
File Location:
scripts/gameltbook_api.py, lines 13-34
Vulnerability Type: Unrestricted credential forwarding
Risk Level: HighVulnerable Code
python parser = argparse.ArgumentParser() parser.add_argument("method") parser.add_argument("url") parser.add_argument("--token", required=True) parser.add_argument("--data") parser.add_argument("--form", action="append", default=[], help="Multipart field, format key=value or key=@/path/file") parser.add_argument("--insecure", action="store_true") args = parser.parse_args() headers = {"X-GameltBook-Token": args.token} context = ssl._create_unverified_context() if args.insecure else None if args.form: return _send_multipart(args, headers, context) body = None if args.data is not None: body = args.data.encode("utf-8") headers["Content-Type"] = "application/json" req = urllib.request.Request(args.url, data=body, method=args.method.upper(), headers=headers)The multipart path uses the same unrestricted URL and authentication header:
python req = urllib.request.Request(args.url, data=bytes(body), method=args.method.upper(), headers=headers)Technical Analysis
The destination URL is entirely caller-controlled, but the
X-GameltBook-Tokenauthentication credential is attached unconditionally. The implementation does not verify the URL scheme, hostname, port, resolved address, or origin.Consequently, the helper can send the credential to an attacker-controlled server rather than the documented GameltBook API. It can also be directed to plain HTTP, loopback services, private-network services, or link-local addresses. Redirect behavior is not explicitly constrained to the original trusted origin.
This violates the principle of least privilege: an API-specific authentication token should only be transmitted to the exact trusted API origin for which it was issued.
Attack Path
...[truncated 1120 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace the unrestricted URL argument with a relative API path joined to a fixed, trusted base URL.
- If custom URLs are required, allow only
https://gameltbook.2lh2o.com:8000after canonical URL parsing. - Reject user information in URLs, fragments, unsupported ports, plain HTTP, and malformed hostnames.
- Resolve the destination and reject loopback, private, link-local, multicast, and reserved addresses unless an explicitly approved deployment requires them.
- Disable automatic redirects or validate every redirect target. Never forward authentication headers across origins.
- Add the authentication header only after destination validation succeeds.
- Add automated tests for attacker domains, alternate ports, HTTP URLs, encoded hostnames, redirects, loopback addresses, and private IP addresses.
- Rotate any token that may already have been used with an untrusted destination.
