T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/onebot_ws_listener.py:81
- Finding
- Unredacted OneBot Events Expose Message and Identity Data in Logs<![CDATA[ ## Vulnerability Details **File Location**: `scripts/onebot_ws_listener.py:81-87` **Vulnerability Type**: Sensitive data exposure through unrestricted event logging **Risk Level**: Medium ### Vulnerable Code ```python message = await ws.recv() event = json.loads(message) # Print event for debugging print(f"\n[Event] {json.dumps(event, ensure_ascii=False, indent=2)}") # Handle event await self._handle_event(event) ``` Additional event data is printed by the example handlers at `scripts/onebot_ws_listener.py:119-120`, `scripts/onebot_ws_listener.py:133-134`, and `scripts/onebot_ws_listener.py:138-140`: ```python user_id = event.get("user_id") message = event.get("message") print(f"[Private] {user_id}: {message}") ``` ```python message = event.get("message") print(f"[Group {group_id}] {user_id}: {message}") ``` ```python notice_type = event.get("notice_type") print(f"[Notice] {notice_type}: {event}") ``` ### Technical Analysis Every received OneBot event is serialized and written to standard output without redaction, filtering, or an opt-in debug setting. Events can contain private or group message contents, QQ user identifiers, group identifiers, message identifiers, timestamps, and notice metadata. Standard output is frequently captured by container runtimes, service managers, CI systems, terminal recorders, or centralized logging platforms. Consequently, data that is only intended for message processing may be retained and exposed to parties with log access. The handler-level logging duplicates this exposure even if the full-event statement is later removed. ### Attack Path 1. An attacker or ordinary user sends a private or group message to the bot. 2. The OneBot server forwards the resulting event over WebSocket. 3. The listener parses and serializes the complete event. 4. The event and its sensitive fields are written to standard output. 5. A process supervisor, container platform, or logging service retains that output. 6. A user with ...[truncated 527 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove full-event logging from the default execution path. - Introduce an explicit debug flag that defaults to disabled. - Log only operational metadata needed for troubleshooting, such as event type and a generated correlation identifier. - Redact message bodies, authorization data, QQ identifiers, group identifiers, and other personal data before logging. - Apply the same redaction policy to all example handlers. - Configure restrictive access controls, short retention periods, and encryption for any logs that must contain message metadata. - Document that production deployments must not enable verbose event logging without a privacy and retention review. ]]>
