Skip to content

[Security/DoS] Memory Exhaustion via Unbounded File Upload in upload_file.py #1005

@sonusharma6-dsa

Description

@sonusharma6-dsa

Summary

The /validate endpoint in backend/app/routers/upload_file.py reads the entire uploaded file into memory using filecontent = await file.read() before checking if filesize > max_file_size. If a user uploads an extremely large file, the server will read it entirely into RAM, bypassing the intended size limit and causing an Out-Of-Memory (OOM) crash.

Impact

An attacker can perform a resource exhaustion (DoS) attack by uploading massive files, dropping the service for all users.

Proposed Fix

Verify file.size metadata if available, or read the file in chunks and abort if the accumulated chunk size exceeds max_file_size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions