# 漏洞总结 ## 漏洞概述 该漏洞涉及文件上传功能中认证检查的缺失。在 `meditor/views.py` 的 `UploadView` 类中,虽然添加了 `upload_require_auth` 配置项用于控制是否需要认证,但实际逻辑存在缺陷:当 `upload_require_auth` 为 `False` 时,系统未正确跳过认证检查,导致未授权用户仍可上传文件。 ## 影响范围 - 受影响文件:`meditor/views.py` - 影响功能:图片上传接口(`/editor/upload-image-file`) - 影响版本:commit 3e80f9e 之前的所有版本 - 风险等级:高(未授权文件上传可能导致服务器被控制、数据泄露等) ## 修复方案 1. 在 `meditor/configs.py` 中新增配置项 `upload_require_auth`,默认值为 `False` 2. 在 `meditor/views.py` 的 `UploadView.post()` 方法中,根据 `upload_require_auth` 配置决定是否执行认证检查: - 当 `upload_require_auth` 为 `True` 时,检查用户是否已认证 - 当 `upload_require_auth` 为 `False` 时,跳过认证检查 ## POC代码 ```python # meditor/views.py 中的关键代码片段 class UploadView(generic.View): """ upload image file """ def post(self, request, *args, **kwargs): upload_image = request.FILES.get('editorod-image-file', None) media_root = settings.MEDIA_ROOT upload_require_auth = MEDITOR_CONFIGS.get('upload_require_auth', False) # Check if user is authenticated if it is required if upload_require_auth and not request.user.is_authenticated: return JsonResponse({ 'success': 0, 'message': "Authentication required.", 'url': "" }) # image none check if not upload_image: return JsonResponse({ 'success': 0, 'message': "File format not recognized.", 'url': "" }) try: Image.open(upload_image) except: return JsonResponse({ 'success': 0, 'message': "File format not recognized.", 'url': "" }) # image folder check file_path = os.path.join(media_root, MEDITOR_CONFIGS['image_folder']) if not os.path.exists(file_path): os.makedirs(file_path) ```