From 3c7956e8c8db344a09b990780a86c6c79b91b203 Mon Sep 17 00:00:00 2001 From: VectorPeak <73048950+VectorPeak@users.noreply.github.com> Date: Wed, 24 Jun 2026 15:55:53 +0800 Subject: [PATCH] fix: prevent path traversal in plugin upload filenames (#8968) --- astrbot/dashboard/services/plugin_service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/astrbot/dashboard/services/plugin_service.py b/astrbot/dashboard/services/plugin_service.py index 0e4d12176..02ea678f1 100644 --- a/astrbot/dashboard/services/plugin_service.py +++ b/astrbot/dashboard/services/plugin_service.py @@ -872,9 +872,10 @@ class PluginService: ) -> tuple[dict, str]: self._ensure_not_demo() logger.info(f"正在安装用户上传的插件 {upload_file.filename}") + filename = str(upload_file.filename or "plugin.zip").replace("\\", "/") file_path = os.path.join( get_astrbot_temp_path(), - f"plugin_upload_{upload_file.filename}", + f"plugin_upload_{os.path.basename(filename) or 'plugin.zip'}", ) await upload_file.save(file_path) try: