本仓库包含一个针对 django-summernote 0.8.20.0(及更早版本)中发现的**条件远程代码执行(RCE)**漏洞的概念验证(PoC)。
该漏洞源于 setup.py 中未严格强制依赖,以及 forms.py 中的回退逻辑。
django-summernote 包将 Pillow 库(严格图像验证所需)视为可选依赖。如果服务器上未安装 Pillow,UploadForm 会将文件输入字段从 forms.ImageField 优雅地降级为通用的 forms.FileField。
漏洞代码(forms.py):
try:
from PIL import Image
FIELD = forms.ImageField # Validates image content
except ImportError:
FIELD = forms.FileField # Accepts ANY file type (Dangerous)
由于 views.py 仅依赖表单验证,此行为允许攻击者上传任意文件(例如 .php、.py、.sh、.html)而非图片,从而导致**远程代码执行(RCE)**或 XSS。
安装不含 Pillow 的 django-summernote:
pip install django-summernote
pip uninstall Pillow # Ensure Pillow is gone
运行 PoC:
python3 poc.py
预期输出:
[+] Verified: Pillow is NOT installed. Vulnerable logic active.
[*] Attempting to upload a Web Shell (.php)...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[!!!] VULNERABILITY SUCCESS: SHELL UPLOADED [!!!]
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[+] Form Validation Passed for: exploit.php
用户应确保在其环境中安装 Pillow,以强制执行图像验证:
pip install Pillow
维护者应将 Pillow 移至 setup.py 的 install_requires 中,或将 ImageField 的使用强制设为硬依赖。