Django server protection against WebSocket Flood attack

I have a django application that works as follows: the user through an ajax request uploads a file to the server for processing -> a celery task is created to process this file -> the user receives a response in the form of some unique key -> the user establishes a websocket connection with the server using of this key (the name of the room is created based on it) -> when the processing of the file is completed, the server will send a message to the room by the key and on client whe he received the message then connection will be closed.

The url for connecting via websocket connection looks like this - ws/download_result/<str:key>/

I also store the keys by which the websocket connection is established in the database, and therefore when someone tries to establish a third-party connection (if he was not on the site and did not give the file for processing and accordingly there is no key - because with each file processing a new key is created - for in order to be able to connect to the server through it and get a result) then I can check whether such a key exists in the database or not, and if not, then reject the connection request. Keys are stored in the database for 1 hour.

But I have a problem - how to protect the server from an attacker who will try to create many connections with the help of one or more valid keys(valid urls for connections)?

Back to Top