| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| astrbot | pip | >= 3.4.4, <= 3.5.12 | 3.5.13 |
The vulnerability is a path traversal in the /api/chat/get_file endpoint, which is handled by the get_file method of the ChatView class in astrbot/dashboard/routes/chat.py. The provided commit cceadf222c46813c7f41115b40d371e7eb91e492 shows the exact changes made to this function to fix the vulnerability. Specifically, the original code concatenated a user-provided filename with a base directory without proper sanitization. The patch introduces the use of os.path.basename() to extract only the filename and os.path.realpath() to resolve the absolute path, followed by a check to ensure this path is within the allowed self.imgs_dir. This directly addresses the path traversal. The exploit curl -L http://0.0.0.0:6185/api/chat/get_file?filename=../../../data/cmd_config.json confirms that this endpoint and the filename parameter were the vector for the attack. The auth_middleware function in astrbot/dashboard/server.py was also modified to remove /api/chat/get_file from allowed_endpoints that bypass authentication, which is a secondary hardening measure but the primary flaw was in get_file's handling of the filename parameter.