T09 · Insecure Skill Coding Practices
Warning
- Location
- feishu_bot.py:267
- Finding
- Unrestricted Webhook Destination Enables Server-Side Request Forgery## Vulnerability Details **File Location**: `feishu_bot.py:267-274` **Vulnerability Type**: Server-Side Request Forgery (SSRF) and unintended data disclosure **Risk Level**: Medium ```python @staticmethod def send_webhook(webhook_url: str, msg_type: str, content: Union[str, Dict]) -> Dict: """Send message via webhook (no auth required)""" data = { "msg_type": msg_type, "content": {"text": content} if msg_type == "text" else content } resp = requests.post(webhook_url, json=data) return resp.json() ``` ### Technical Analysis The `send_webhook` method passes a caller-controlled `webhook_url` directly to `requests.post`. It does not enforce HTTPS, restrict destinations to documented Feishu webhook domains, validate the resolved IP address, or reject loopback, private, link-local, and reserved network ranges. Redirects are also accepted under the `requests` library's default behavior without revalidating the resulting destination. Although webhook delivery is part of the declared functionality, accepting arbitrary destinations exceeds the minimum network privileges required for a Feishu-specific integration. If an agent derives this parameter from untrusted instructions or message content, an attacker can cause the trusted runtime to send requests to systems that are inaccessible from the attacker's own network position. The request body contains caller-provided message content. Consequently, the same behavior can disclose that content to an unintended or attacker-controlled destination. ### Attack Path 1. An attacker provides an agent with a crafted URL, such as a loopback address, private network service, link-local endpoint, or attacker-controlled redirect. 2. The agent passes that URL to `FeishuBot.send_webhook`. 3. The method performs an HTTP POST from the trusted execution environment without destination validation. 4. The target receives the supplied JSON body and may proc ...[truncated 1032 chars]
- Remediation
- ## Remediation Suggestions - Restrict webhook destinations to documented Feishu/Lark webhook hosts using an exact hostname allowlist. - Require HTTPS and reject URLs containing embedded credentials, unexpected ports, or malformed hostnames. - Resolve the destination before connecting and reject loopback, private, link-local, multicast, unspecified, and reserved IPv4 and IPv6 ranges. - Disable redirects with `allow_redirects=False`, or validate the scheme, hostname, resolved address, and port again for every redirect. - Protect against DNS rebinding by ensuring that validation and connection use a consistently validated destination. - Add an explicit policy or user-confirmation step before permitting delivery to any non-Feishu endpoint. - Apply bounded request timeouts and limit the maximum response size. - Treat webhook content as potentially sensitive and avoid sending it to destinations that have not been explicitly authorized.
