T09 · Insecure Skill Coding Practices
- Location
scripts/check_new_messages.py:92- Finding
Bearer API Credential Can Be Transmitted over Unencrypted HTTP
- Content
View full analysis
Vulnerability Details
File Location:
scripts/check_new_messages.py:55-56andscripts/check_new_messages.py:92-105
Vulnerability Type: Unrestricted destination and insecure transport for sensitive authentication data
Risk Level: MediumVulnerable Code
python base_url = env_required("GATEWAY_BASE_URL").rstrip("/") api_key = env_required("GATEWAY_API_KEY")python def api_request(cfg: Config, method: str, path: str, payload: dict[str, Any] | None = None) -> dict[str, Any]: url = f"{cfg.base_url}{path}" body = None headers = { "Authorization": f"Bearer {cfg.api_key}", "Content-Type": "application/json", } if payload is not None: body = json.dumps(payload).encode("utf-8") req = request.Request(url=url, method=method, data=body, headers=headers) try: with request.urlopen(req, timeout=30) as resp:The documentation explicitly presents a cleartext URL as the configuration example:
markdown - `GATEWAY_BASE_URL` (example: `http://localhost:8000`)Technical Analysis
The helper reads
GATEWAY_BASE_URLdirectly from the environment and attaches the bearer API key to every request without validating the URL scheme or destination. Although plain HTTP can be acceptable for a gateway strictly bound to a loopback interface, the implementation also accepts remote HTTP destinations.When a remote cleartext destination is supplied, the bearer credential, account identifiers, synchronization parameters, draft contents, and retrieved mailbox information can traverse the network without encryption. The configured server receives the bearer token by design, so an erroneous or attacker-influenced environment configuration can also disclose it to an unintended endpoint.
No hard-coded exfiltration destination was found. Exploitation requires control over configuration, DNS or network traffic, or the configured gatew ...[truncated 1410 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse
GATEWAY_BASE_URLwithurllib.parse.urlsplitbefore making requests. - Require
httpsfor every non-loopback destination. - Permit plain HTTP only when the resolved destination is explicitly limited to
localhost,127.0.0.0/8, or::1. - Reject unsupported schemes, URLs containing embedded credentials, fragments, and malformed hostnames.
- Consider a configurable allowlist of trusted gateway hostnames and ports.
- Prevent HTTPS-to-HTTP redirects, particularly because authorization headers may be exposed or requests may be downgraded.
- Use valid certificate verification and avoid adding options that disable TLS validation.
- Issue narrowly scoped, revocable credentials per installation or account rather than one broadly privileged token.
- Replace the generic HTTP example in
SKILL.mdandapi-reference.mdwith an HTTPS example. Clearly state that HTTP is allowed only for a loopback-only deployment. - Rotate the API key immediately if it may previously have been used with a remote HTTP endpoint.
- Parse
