Step 1: Payload Crafting: The attacker crafts a malicious WebSocket message. This message contains a payload designed to be significantly larger than expected or reasonable for the application's normal operation.
Step 2: Message Transmission: The attacker sends the crafted WebSocket message to the vulnerable server using a WebSocket connection.
Step 3: Server Processing: The server, using the vulnerable ws crate, receives and attempts to process the malicious message.
Step 4: Buffer Allocation: Due to the lack of proper size validation, the server allocates a large buffer to accommodate the oversized payload.
Step 5: Memory Exhaustion: The server either allocates an extremely large buffer, leading to memory exhaustion, or attempts to write the oversized payload, potentially triggering a buffer overflow or other memory corruption issues, ultimately leading to a crash or denial of service.