T09 · Insecure Skill Coding Practices
- Location
scripts/langfuse_openclaw_optimizer.py:143- Finding
Langfuse credentials can be transmitted to an unrestricted user-configurable host
- Content
View full analysis
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 PracticesVulnerable 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
View remediation
Remediation Suggestions
- Parse the configured host with
urllib.parse.urlsplitand reject every scheme other thanhttps. - Use an explicit allowlist of trusted Langfuse origins by default, such as
https://us.cloud.langfuse.com. - For self-hosted deployments, require an explicit opt-in flag and display or log the normalized credential destination before sending a request.
- Reject URLs containing user information, fragments, unexpected paths, malformed ports, or ambiguous hostnames.
- Prevent silent cross-origin redirects for authenticated requests, or strip the
Authorizationheader whenever the origin changes. - Protect the persisted configuration with restrictive filesystem permissions so untrusted local users cannot replace the host.
- Use dedicated, read-only, minimally scoped Langfuse credentials for telemetry retrieval.
- Document that changing
langfuse_hostchanges the destination receiving the Langfuse secret key.
- Parse the configured host with
