xiaozhi-esp32-server-java
by joey-zhou
Overview
Java backend for ESP32 smart hardware devices, providing a management platform with AI agent capabilities for intelligent device control and interactive voice features.
Installation
docker-compose up -dEnvironment Variables
- SPRING_DATASOURCE_URL
- SPRING_DATASOURCE_USERNAME
- SPRING_DATASOURCE_PASSWORD
- SPRING_DATA_REDIS_HOST
- SPRING_DATA_REDIS_PORT
- SPRING_DATA_REDIS_PASSWORD
- WECHAT_APPID
- WECHAT_SECRET
- SMS_ALIYUN_ACCESS_KEY_ID
- SMS_ALIYUN_ACCESS_KEY_SECRET
- SMS_ALIYUN_SIGN_NAME
- SMS_ALIYUN_TEMPLATE_CODE
- EMAIL_SMTP_USERNAME
- EMAIL_SMTP_PASSWORD
- XIAOZHI_UPLOAD_PATH
- XIAOZHI_COMMUNICATION_PROTOCOL
- XIAOZHI_SERVER_DOMAIN
- CHECK_INACTIVE_SESSION
- INACTIVE_TIMEOUT_SECONDS
- TTS_TIMEOUT_MS
- TTS_MAX_RETRY_COUNT
- TTS_RETRY_DELAY_MS
- TTS_MAX_CONCURRENT_PER_SESSION
- VAD_PREBUFFER_MS
- VAD_TAIL_KEEP_MS
- VAD_AUDIO_ENHANCEMENT_ENABLED
- VAD_MODEL_PATH
- XIAOZHI_MCP_DEVICE_MAX_TOOLS_COUNT
- COS_SECRETID
- COS_SECRETKEY
- COS_BUCKETNAME
- COS_REGION
Security Notes
CRITICAL VULNERABILITIES DETECTED: 1. **Unauthenticated Virtual Device Creation/Access via `user_chat_` deviceId:** The `MessageHandler.handleUnboundDevice` function attempts to automatically bind new WebSocket connections if their `device-id` starts with `user_chat_` followed by a user ID (e.g., `user_chat_1`). If a virtual device for that specific `device-id` does not exist in the database, the system will *create* one and associate it with the extracted `userId`. This allows any malicious actor to create or take over a virtual device linked to any existing user account (including administrator accounts, e.g., `userId=1`) simply by spoofing the `device-id` in the connection request. This is a critical authentication bypass that grants unauthorized access to user-specific virtual devices and potentially associated functionalities. 2. **Weak Device Authentication on WebSocket:** The `WebSocketHandler.afterConnectionEstablished` method has commented-out code for token-based authentication. In its current active state, device authentication relies solely on the `device-id` header or URI parameter. This `device-id` is easily spoofed, enabling unauthorized physical devices to impersonate legitimate ones and gain control over their associated roles and functionalities. 3. **Storage of Sensitive API Keys in Database:** API keys and secrets for numerous external LLM, STT, and TTS services (e.g., OpenAI, Aliyun, Coze, Dify) are stored directly in plaintext or weakly encrypted format within the `sys_config` database table. While common, this practice makes the entire system highly vulnerable to database breaches. A compromise of the database would immediately expose all integrated service credentials, posing a significant security risk.
Similar Servers
xiaozhi-esp32-server
Provides a robust backend service for the Xiaozhi ESP32 intelligent terminal hardware, enabling AI assistant functionalities such as voice recognition, natural language processing, knowledge base integration, voice cloning, and device control through MQTT, Websocket, and MCP protocols.
solon-ai
A framework for building AI agents and applications that communicate via the Model Context Protocol (MCP) to interact with diverse AI services, tools, and resources.
ha-mcp
A Model Context Protocol server that provides complete control over Home Assistant through REST API and WebSocket integration with a wide array of enhanced tools.
IntelliConnect
An intelligent IoT platform leveraging AI agents, large language models, and various IoT protocols for smart device management and voice-controlled applications.