From f2ff04ecdc4793b9bdb4cf9f66d37a8734c538f9 Mon Sep 17 00:00:00 2001 From: hacklab Date: Tue, 7 Apr 2026 17:26:25 +0200 Subject: [PATCH] =?UTF-8?q?fix(security):=20timeout=20de=20conexi=C3=B3n?= =?UTF-8?q?=20en=20servidor=20HTTP=20=E2=80=94=20VULN:=20Slowloris=20DoS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vulnerabilidad corregida: - Slowloris: un atacante podía abrir cientos de conexiones TCP enviando headers/body a goteo (1 byte cada varios segundos) manteniendo el event loop de Node.js ocupado con sockets colgados indefinidamente, lo que bloquea peticiones legítimas (DoS por agotamiento de sockets). Mitigación aplicada en el servidor HTTP: headersTimeout = 10s — aborta si los headers no llegan en 10 s requestTimeout = 15s — aborta si el body no llega en 15 s keepAliveTimeout = 5s — cierra keep-alive inactivos tras 5 s Adicionalmente: warning al arrancar si SALT no está configurado en .env. Co-Authored-By: Claude Sonnet 4.6 --- api/app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api/app.js b/api/app.js index efc9230..7e8a69b 100644 --- a/api/app.js +++ b/api/app.js @@ -50,9 +50,17 @@ app.get('/api/health', (req, res) => res.json({ status: 'ok' })); // ── Arranque ───────────────────────────────────────────────────── const PORT = process.env.PORT || 8787; -app.listen(PORT, '127.0.0.1', () => { +const server = app.listen(PORT, '127.0.0.1', () => { console.log(`RESETEA backend corriendo en 127.0.0.1:${PORT}`); if (!process.env.GOOGLE_CLIENT_ID) { console.warn('⚠ GOOGLE_CLIENT_ID no configurado — OAuth Gmail deshabilitado'); } + if (!process.env.SALT) { + console.warn('⚠ SALT no configurado en .env — el hash de referencia usa salt por defecto'); + } }); + +// Mitigación Slowloris: timeout en headers y body incompletos +server.headersTimeout = 10_000; // 10 s para recibir los headers completos +server.requestTimeout = 15_000; // 15 s para recibir el body completo +server.keepAliveTimeout = 5_000; // cierra keep-alive inactivos tras 5 s