From 9bfdd95cb61462c77ada1ace84d3d56a59065a4d Mon Sep 17 00:00:00 2001 From: fl0l0u Date: Sun, 15 Nov 2026 17:21:21 +0000 Subject: [PATCH] server: a wrong api key closes the connection it guessed on A failed authentication answered 401 and kept the connection alive, so a client guessing credentials over one keep-alive paid for the socket once and then streamed a thousand tries down it. The gate can refuse the request; it was not refusing the session. The 401 now carries Connection: close. A guessing client pays a fresh connect -- and on TLS, a fresh handshake -- per guess, while every correctly-keyed request keeps its warm connection untouched. --- core/server/http.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/server/http.cpp b/core/server/http.cpp index 04af489f..eb900539 100644 --- a/core/server/http.cpp +++ b/core/server/http.cpp @@ -763,6 +763,9 @@ int HttpTransport::serve(const Router& router, const TransportOptions& o) { hres.status = 401; hres.set_content(error_body(p, 401, "authentication_error", "invalid api key"), "application/json"); + /* Close over it: a credential-guessing client should pay a fresh TLS/TCP setup + * per try, not one keep-alive for a thousand. */ + hres.set_header("Connection", "close"); return false; } }