T09 · Insecure Skill Coding Practices
- Location
scripts/send_blessing.py:58- Finding
Configurable Operations Endpoint Can Expose Bearer Tokens and Private Message Data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/send_blessing.py, lines 58–77
Vulnerability Type: Unrestricted destination and missing HTTPS enforcement for sensitive outbound requests
Risk Level: MediumVulnerable Code
python def post_operation(operation_type: str, payload: dict[str, Any], code: str, timeout: float) -> Any: url = os.getenv("WX_OPENCLAW_OPS_URL", "").strip() token = os.getenv("WX_OPENCLAW_OPS_TOKEN", "").strip() if not url or not token: raise UsageError("WX_OPENCLAW_OPS_URL and WX_OPENCLAW_OPS_TOKEN are required for execution") request_id = f"skill-{uuid.uuid4().hex}" request = urllib.request.Request( url, data=json.dumps( { "version": "1.0", "requestId": request_id, "operationType": operation_type, "channel": "OPENCLAW", "payload": payload, }, ensure_ascii=False, ).encode("utf-8"), method="POST", headers={ "Authorization": f"Bearer {token}", "Content-Type": "application/json; charset=utf-8", "X-Confirmation-Code": code, "User-Agent": "wechat-blessings/1.0", }, )Technical Analysis
The operations endpoint is read directly from
WX_OPENCLAW_OPS_URLand used without validating its scheme, hostname, port, or origin. The request includes the bearer token in theAuthorizationheader and embeds recipient identifiers, blessing text, scheduling information, and operation metadata in its body.Consequently, an incorrectly configured or attacker-influenced environment can direct the request to an untrusted server. The absence of HTTPS enforcement also permits an
http://endpoint, exposing credentials and message data to network interception or modification.User confirmation does not mitigate this issue be ...[truncated 1573 chars]
- Remediation
View remediation
Remediation Suggestions
- Parse the configured endpoint with
urllib.parse.urlsplitand require thehttpsscheme. - Compare the normalized hostname against a strict allowlist of approved operations-gateway hosts.
- Reject embedded user information, URL fragments, unexpected ports, malformed hostnames, and non-HTTPS endpoints.
- Prevent redirects to a different origin, or validate the scheme and destination again for every redirect before forwarding the authorization header.
- Prefer a gateway origin stored in trusted deployment configuration rather than an environment value modifiable by lower-trust processes.
- Use short-lived, narrowly scoped tokens limited to the required messaging operations.
- Add automated tests confirming rejection of HTTP URLs, attacker-controlled hosts, embedded credentials, unexpected ports, and cross-origin redirects.
- Avoid including sensitive server response bodies in error output unless they are explicitly redacted.
- Parse the configured endpoint with
