Python-Multipart is a streaming multipart parser for Python. Prior to version 0.0.22, a Path Traversal vulnerability exists when using non-default configuration options `UPLOAD_DIR` and `UPLOAD_KEEP_FILENAME=True`. An attacker can write uploaded files to arbitrary locations on the filesystem by crafting a malicious filename. Users should upgrade to version 0.0.22 to receive a patch or, as a workaround, avoid using `UPLOAD_KEEP_FILENAME=True` in project configurations.
CVE-2026-24486 is a critical path traversal vulnerability in Python-Multipart library affecting file upload functionality. When non-default configurations (UPLOAD_DIR and UPLOAD_KEEP_FILENAME=True) are enabled, attackers can write files to arbitrary filesystem locations, potentially leading to remote code execution or system compromise. An exploit is publicly available, making this an urgent threat requiring immediate patching to version 0.0.22 or configuration remediation.
IMMEDIATE ACTIONS:
1. Identify all systems using Python-Multipart library by scanning requirements.txt, setup.py, and dependency manifests
2. Check configuration files for UPLOAD_KEEP_FILENAME=True setting - this is the critical trigger
3. If UPLOAD_KEEP_FILENAME=True is enabled, immediately disable it as temporary mitigation
PATCHING:
1. Upgrade Python-Multipart to version 0.0.22 or later: pip install --upgrade python-multipart>=0.0.22
2. Update all FastAPI and dependent applications using this library
3. Restart affected web services after patching
4. Verify patch installation: python -c "import multipart; print(multipart.__version__)"
COMPENSATING CONTROLS (if immediate patching not possible):
1. Disable UPLOAD_KEEP_FILENAME=True in all configurations
2. Implement strict input validation on filenames - reject path traversal characters (../, ..\\ , null bytes)
3. Use allowlist-based filename validation accepting only alphanumeric characters and safe symbols
4. Enforce file uploads to isolated directories with restricted permissions (chmod 755)
5. Implement Web Application Firewall (WAF) rules to detect path traversal patterns in upload requests
DETECTION:
1. Monitor file system for unexpected file creation in system directories (/etc, /var, /usr, /bin, /sbin, Windows: C:\\Windows, C:\\Program Files)
2. Log all file upload requests and validate filename patterns
3. Alert on filenames containing: ../, ..\\ , %2e%2e, encoded traversal sequences
4. Monitor Python process file descriptor activity for writes outside designated upload directories
5. Implement SIEM rules: detect_path_traversal_upload_attempts
الإجراءات الفورية:
1. تحديد جميع الأنظمة التي تستخدم مكتبة Python-Multipart من خلال مسح ملفات requirements.txt و setup.py
2. التحقق من ملفات التكوين لإعداد UPLOAD_KEEP_FILENAME=True - هذا هو المحفز الحرج
3. إذا كان UPLOAD_KEEP_FILENAME=True مفعلاً، قم بتعطيله فوراً كتخفيف مؤقت
التصحيح:
1. ترقية Python-Multipart إلى الإصدار 0.0.22 أو أحدث: pip install --upgrade python-multipart>=0.0.22
2. تحديث جميع تطبيقات FastAPI والتطبيقات التابعة التي تستخدم هذه المكتبة
3. إعادة تشغيل الخدمات المتأثرة بعد التصحيح
4. التحقق من تثبيت التصحيح: python -c "import multipart; print(multipart.__version__)"
الضوابط البديلة (إذا لم يكن التصحيح الفوري ممكناً):
1. تعطيل UPLOAD_KEEP_FILENAME=True في جميع التكوينات
2. تطبيق التحقق الصارم من صحة أسماء الملفات - رفض أحرف الاجتياز (../, ..\\، بايتات فارغة)
3. استخدام التحقق من أسماء الملفات القائم على القائمة البيضاء
4. فرض تحميل الملفات إلى دلائل معزولة بأذونات مقيدة
5. تطبيق قواعد جدار حماية تطبيقات الويب للكشف عن أنماط الاجتياز
الكشف:
1. مراقبة نظام الملفات للكشف عن إنشاء ملفات غير متوقعة في دلائل النظام
2. تسجيل جميع طلبات تحميل الملفات والتحقق من أنماط أسماء الملفات
3. التنبيه على أسماء الملفات التي تحتوي على أحرف الاجتياز
4. مراقبة نشاط وصف ملف عملية Python
5. تطبيق قواعد SIEM للكشف عن محاولات الاجتياز