Skip to content

Commit 95d207b

Browse files
committed
security: harden backend (CORS, trustProxy, rate-limit, upload validation, nosniff)
- Fix refresh-token invalidation bug: invalid tokens no longer wipe all sessions globally (auth.ts) - Replace wildcard CORS with config-driven origin allowlist. Default: no CORS headers. Configurable via allowedOrigins in backend-config.json or ALLOWED_ORIGINS env var (comma-separated) - Add trustProxy config flag (default false). x-forwarded-* headers are now ignored unless explicitly opted in - Add in-memory brute-force rate limiting for login and groupLogin: 7 failed attempts → 15-minute block (HTTP 429) - Validate image uploads by magic bytes (PNG/JPEG/WEBP), not just file extension - Add X-Content-Type-Options: nosniff to all static file responses Signed-off-by: Mike Lischke <mike@lischke-online.de>
1 parent fdfd0a0 commit 95d207b

2 files changed

Lines changed: 253 additions & 14 deletions

File tree

src/server/auth.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ export const verifyAndRotateRefreshToken = async (adapter: IDatabaseAdapter,
263263
);
264264

265265
if (rows.length === 0) {
266-
await adapter.execute("UPDATE users SET refresh_token_hash = NULL WHERE refresh_token_hash IS NOT NULL");
267-
268266
return undefined;
269267
}
270268

0 commit comments

Comments
 (0)