diff --git a/Telepathy/ThreadFunctions.cs b/Telepathy/ThreadFunctions.cs index 066a932..8f8114c 100644 --- a/Telepathy/ThreadFunctions.cs +++ b/Telepathy/ThreadFunctions.cs @@ -68,6 +68,17 @@ public static bool ReadMessageBlocking(NetworkStream stream, int MaxMessageSize, // read exactly 'size' bytes for content (blocking) return stream.ReadExactly(payloadBuffer, size); } + + //PATCH — Aggressive disconnect, close stream immediately to prevent attacker from sending more data before it closes in ReceiveLoop + try + { + stream.Close(); // drop connection before returning + } + catch (Exception ex) + { + Log.Info("Exception while closing stream after header attack: " + ex); + } + Log.Warning("[Telepathy] ReadMessageBlocking: possible header attack with a header of: " + size + " bytes."); return false; } @@ -241,4 +252,4 @@ public static void SendLoop(int connectionId, TcpClient client, MagnificentSendP } } } -} \ No newline at end of file +}