T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/langfuse_openclaw_optimizer.py:143
- Finding
- Langfuse credentials can be transmitted to an unrestricted user-configurable host## Vulnerability Details **File Location**: `scripts/langfuse_openclaw_optimizer.py`, lines 143-146, 193-210, 418-445, and 520-522 **Vulnerability Type**: Unrestricted credential transmission destination **Risk Level**: High **Category**: T09: Insecure Skill Coding Practices ### Vulnerable Code ```python def basic_auth_header(public_key: str, secret_key: str) -> str: raw = f"{public_key}:{secret_key}".encode("utf-8") token = base64.b64encode(raw).decode("ascii") return f"Basic {token}" ``` ```python query = urlencode(params, doseq=True) url = f"{host}{endpoint}?{query}" req = Request( url=url, method="GET", headers={ "Authorization": auth_header, "Accept": "application/json", }, ) with urlopen(req, timeout=timeout_sec) as resp: payload = json.loads(resp.read().decode("utf-8")) ``` ```python auth = basic_auth_header(public_key, secret_key) obs_params = {} if args.environment: obs_params["environment"] = args.environment observations = fetch_langfuse_items( host=args.langfuse_host, endpoint="/api/public/v2/observations", auth_header=auth, from_ts=from_ts, to_ts=to_ts, limit=args.limit, max_pages=args.max_pages, extra_params=obs_params, timeout_sec=args.http_timeout_sec, ) ``` ```python p.add_argument("--langfuse-host", default=None, help="LangFuse host URL.") p.add_argument("--langfuse-public-key", default=None, help="LangFuse public key (or LANGFUSE_PUBLIC_KEY env).") p.add_argument("--langfuse-secret-key", default=None, help="LangFuse secret key (or LANGFUSE_SECRET_KEY env).") ``` ### Technical Analysis The Base64 operation is the normal encoding required by HTTP Basic au ...[truncated 2162 chars]
- Remediation
- ## Remediation Suggestions 1. Parse the configured host with `urllib.parse.urlsplit` and reject every scheme other than `https`. 2. Use an explicit allowlist of trusted Langfuse origins by default, such as `https://us.cloud.langfuse.com`. 3. For self-hosted deployments, require an explicit opt-in flag and display or log the normalized credential destination before sending a request. 4. Reject URLs containing user information, fragments, unexpected paths, malformed ports, or ambiguous hostnames. 5. Prevent silent cross-origin redirects for authenticated requests, or strip the `Authorization` header whenever the origin changes. 6. Protect the persisted configuration with restrictive filesystem permissions so untrusted local users cannot replace the host. 7. Use dedicated, read-only, minimally scoped Langfuse credentials for telemetry retrieval. 8. Document that changing `langfuse_host` changes the destination receiving the Langfuse secret key.
