T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/wechat.py:1694
- Finding
- Private WeChat Messages and API Credentials Can Be Transmitted to Arbitrary Plaintext Endpoints<![CDATA[ ## Vulnerability Details **File Location**: `scripts/wechat.py:1410-1411`, `scripts/wechat.py:1453-1455`, and `scripts/wechat.py:1694-1728` **Vulnerability Type**: Unrestricted sensitive-data transmission over potentially insecure transport **Risk Level**: High ### Vulnerable Code ```python def auto_process_contacts(self, contact_list: List[str], max_polling_times: int = 10, api_url: str = "http://localhost:8000/api/chat/message", api_key: str = "") -> None: ``` ```python latest_messages = self._get_latest_messages(message_rects) if latest_messages: # Call the AI interface to obtain replies ai_replies = self._call_ai_api(latest_messages, api_url, api_key) ``` ```python def _call_ai_api(self, customer_messages: List[str], api_url: str, api_key: str) -> List[Dict[str, Any]]: try: headers = { "Content-Type": "application/json", "Authorization": f"Bearer {api_key}" } # Combine customer messages into one string combined_message = "\n".join(customer_messages) data = { "user_id": "7", "message": combined_message, "username": "" } self.logger.info(f"调用AI接口: {api_url}") self.logger.info( f"请求消息: {len(customer_messages)}条,合并为: " f"{combined_message[:50]}..." ) response = requests.post( api_url, json=data, headers=headers, timeout=30 ) ``` ### Technical Analysis The automatic-reply feature extracts incoming WeChat messages from the desktop interface, joins them into a single string, and submits them verbatim to `api_url`. The request also includes the configured API credential as a bearer token. The destination is entirely controlled through the `--api_url` argument. The implementation does not: - Require HTTPS for non-loopback destinations. - R ...[truncated 2256 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require HTTPS for every non-loopback destination. Permit plaintext HTTP only for explicitly recognized loopback hosts such as `127.0.0.1`, `::1`, or `localhost`. 2. Parse and validate the URL before use, including its scheme, hostname, port, and resolved address. 3. Disable automatic redirects or revalidate every redirect target so an approved HTTPS destination cannot redirect to HTTP or an untrusted host. 4. Provide a configurable allowlist of trusted API origins. 5. Display the destination and a clear data-disclosure notice before the first transmission, and require explicit user consent. 6. Transmit only the minimum message context needed. Add configurable redaction for credentials, financial details, phone numbers, and other personal information. 7. Separate local-only operation from remote AI operation in both the CLI and documentation. 8. Correct the privacy documentation so it clearly states when and where chat content leaves the device. 9. Consider requiring a user confirmation step before API-generated content is sent to a WeChat contact. ]]>
