T09 · Insecure Skill Coding Practices
- Location
scripts/lmail_http.py:60- Finding
Credentials May Be Transmitted to Arbitrary, Cleartext, or Redirected Endpoints
- Content
View full analysis
tuple[int, dict[str, Any]]: req_headers = dict(headers or {}) body = None if payload is not None: body = json.dumps(payload).encode("utf-8") req_headers.setdefault("Content-Type", "application/json") req = request.Request(url=url, data=body, method=method, headers=req_headers) try: with request.urlopen(req, timeout=timeout) as resp: raw = resp.read().decode("utf-8") status = resp.status ``` ```python def auth_headers(token: str | None = None, api_key: str | None = None) -> dict[str, str]: if token: return {"Authorization": f"Bearer {token}"} if api_key: return {"Authorization": f"ApiKey {api_key}"} raise LMailHttpError("Missing auth: provide token or api key") ``` Authenticated callers directly combine these functions with a user- or environment-controlled base URL. For example, `scripts/chat_fast.py:219-222` contains: ```python creds = load_json_file(args.credentials_file) token = args.token or creds.get("token") api_key = args.api_key or creds.get("apiKey") headers = auth_headers(token=token, api_key=api_key) ``` ### Technical Analysis The shared HTTP client accepts any URL supported by `urllib` without validating its scheme, hostname, port, or origin. Most operational scripts accept `--base-url` or `LMAIL_BASE_URL`, load credentials from the local credentials file, and attach the resulting bearer token or API key to requests. The implementation does not: - Require HTTPS for non-loopback destinations. - Restrict authenticated requests to approved LMail origins. - Reject URLs containing ...[truncated 1803 chars]- Remediation
View remediation
