Back to Home
joey-zhou icon

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

Run Command
docker-compose up -d

Environment 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

Stats

Interest Score99
Security Score2
Cost ClassMedium
Avg Tokens500
Stars1019
Forks377
Last Update2025-12-10

Tags

ESP32IoTSmart HomeJavaAI Agent