Summary
Flask-Reuploaded can incorrectly evaluate caller-supplied upload names with case-sensitive extension handling, allowing a dangerous mixed-case extension to bypass a lowercase denylist.
If the uploaded file is stored in a web-served directory and the deployment resolves or executes extensions case-insensitively, an attacker may execute the file with the web server's privileges.
Affected context
The issue affects Flask-Reuploaded configurations that use UploadSet.save() with a caller-controlled name override and an AllExcept extension denylist. It becomes risky when uploaded content is placed in a served directory and the surrounding web server or runtime treats extension casing case-insensitively. Pure extension allowlists and deployments that do not execute uploaded files are generally less exposed.
Exploit preconditions
- Attack surface: File-upload functionality using Flask-Reuploaded
- Required access: Ability to submit an upload and influence the caller-supplied filename
- Trigger point: Extension validation during
UploadSet.save(storage, name=...) - Required configuration: A denylist-based
AllExceptpolicy using lowercase dangerous extensions - Deployment condition: The upload directory is web-served and the server or runtime resolves or executes extensions without case sensitivity
- Why exploitation is possible: The supplied name uses case-preserving extension handling while the denylist comparison expects lowercase values
Why this happens
The vulnerability results from inconsistent canonicalization of file extensions. The default upload path applies lowercase normalization, but a caller-supplied name retains extension casing before it is evaluated against an AllExcept denylist.
A mixed-case dangerous extension can therefore evade a case-sensitive comparison even though it represents the same effective extension to a case-insensitive web server. This maps primarily to CWE-178: Improper Handling of Case Sensitivity and is also related to CWE-434: Unrestricted Upload of File with Dangerous Type.
Potential impact
- An attacker could store a file with a dangerous executable extension in a served upload directory.
- The uploaded file could execute with the web server's privileges.
- Confidentiality, integrity, and availability of the application or host could be affected.
- The issue could enable follow-on compromise depending on process permissions and deployment isolation.
General mitigation guidance
Mitigation generally focuses on eliminating inconsistent filename normalization and reducing trust in client-controlled names.
Common defensive patterns include:
- Canonicalizing extensions using a consistent, case-insensitive policy before validation.
- Preferencing strict allowlists of permitted file types over denylist-only controls.
- Generating server-side storage names rather than preserving user-supplied names.
- Storing uploads outside web-served and execution-capable directories.
- Serving uploaded content with non-executable content-disposition and restrictive response policies.
- Applying least privilege to the web server and upload-processing processes.
- Validating file content and format independently of the filename extension.
How teams detect issues like this
Detection approaches can include:
- Static analysis for extension checks that compare unnormalized user-controlled strings against denylist entries.
- Code review of upload APIs that accept caller-supplied storage names or preserve filename extensions.
- Tests covering mixed-case variants of blocked extensions and different upload storage paths.
- Policy enforcement requiring allowlists, canonicalization, and non-executable upload locations.
- Runtime monitoring for executable content, unexpected extension variants, or process execution from upload directories.
Automated security review tools can help identify inconsistent normalization and dangerous file-upload patterns.

