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.
Summary
The
/validateendpoint inbackend/app/routers/upload_file.pyreads the entire uploaded file into memory usingfilecontent = await file.read()before checking iffilesize > 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.sizemetadata if available, or read the file in chunks and abort if the accumulated chunk size exceedsmax_file_size.