Cross-Site Request Forgery (CSRF) via File Upload is a type of attack where an authenticated user is tricked into uploading a file (often malicious or unintended) to a target application, without their consent, by submitting a file upload form from another domain.
This is possible only if the file upload endpoint is vulnerable to CSRF — i.e., it does not implement proper CSRF protection mechanisms such as tokens or same-site cookie policies.
1. The victim is authenticated to a target application (e.g., company portal).
2. The attacker hosts a page (e.g., on evil.com) with a hidden HTML form targeting the file upload endpoint.
3. The attacker auto-submits or tricks the victim into submitting a request using the victim’s browser (via a POST form) to upload the malicious file or payload.
4. If the upload endpoint lacks CSRF protection, the file is uploaded using the victim’s session cookie.
SameSite=Lax
or SameSite=Strict
.multipart/form-data
for uploads).application/x-www-form-urlencoded
or text/plain
uploads.