Skip to content

Commit b4fac5b

Browse files
author
lagutinl613-alt
committed
fix: increase rate limit to 600/min, relax Host header validation
Dashboard makes many concurrent API calls on load, 100/min was too low. Host validation now checks hostname only (ignores port), allows empty host.
1 parent 474153e commit b4fac5b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/agent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface RateLimitEntry {
3030

3131
const rateLimitMap = new Map<string, RateLimitEntry>();
3232
const RATE_LIMIT_WINDOW_MS = 60 * 1000; // 1 minute
33-
const RATE_LIMIT_MAX_REQUESTS = 100; // 100 requests per minute per IP
33+
const RATE_LIMIT_MAX_REQUESTS = 600; // 600 requests per minute per IP (dashboard makes many API calls)
3434

3535
function checkRateLimit(clientIp: string): boolean {
3636
const now = Date.now();
@@ -110,9 +110,9 @@ function createServer(ctx: ServerContext): http.Server {
110110
}
111111

112112
// HIGH FIX: Host header validation to prevent DNS rebinding attacks
113-
const hostHeader = req.headers.host;
114-
const allowedHosts = [`localhost:${PORT}`, `127.0.0.1:${PORT}`];
115-
if (!hostHeader || !allowedHosts.includes(hostHeader)) {
113+
const hostHeader = req.headers.host?.split(':')[0] || '';
114+
const allowedHosts = ['localhost', '127.0.0.1', '0.0.0.0', ''];
115+
if (hostHeader && !allowedHosts.includes(hostHeader)) {
116116
res.writeHead(400, { 'Content-Type': 'application/json' });
117117
res.end(JSON.stringify({ error: 'Invalid Host header' }));
118118
return;

0 commit comments

Comments
 (0)