Skip to content
File upload Write-up Intermediate

CVE-2023–31047 | Django — Improper Input Validation Zafi

Django's forms.FileField and forms.ImageField did not support multiple file uploads, so when multiple files were uploaded, only the last file was validated. An attacker could upload a malicious file alongside a safe one, bypassing validation and potentially leading to more serious security breaches.

Yunus Olçar Follow

Published on medium.com

Hey, hoş geldin. Bu yazımda Django’da “low” derece olarak sınıflandırılan bir güvenlik açığına yakından bakacağız.

Yunus Olçar, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the form fields were designed for single file uploads and did not properly handle multiple files, so validation only applied to the last file.

Impact

An attacker could upload a malicious file that bypasses validation, potentially leading to more serious security breaches.

What the attacker needed

Django version affected; ability to upload files

The fix

The fix added an allow_multiple_selected option (default false) and raised errors if multiple=True was used without support, and used files.getlist when multiple selection is allowed.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When a website lets you upload files, it should check each file to make sure it is safe. In this case, Django only checked the last file if you uploaded several at once, so a bad file could sneak through. That could let an attacker upload something harmful to the server.

What is File upload?

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

More by Yunus Olçar

View all

6 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.