fix(gateway): security hardening — auth guards, ownership checks, validation, rate limiting #85
Reference in New Issue
Block a user
Delete Branch "fix/gateway-security"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
7 security fixes for the mosaic-mono-v1 gateway:
@UseGuards(AuthGuard)+@CurrentUser()(was unauthenticated)origin: *→process.env["GATEWAY_CORS_ORIGIN"];chat.gateway-auth.tshelper for session validation onhandleConnectionForbiddenExceptionon userId mismatchwhitelist: true, forbidNonWhitelisted: true, transform: true; DTOs updated with@IsString,@IsIn,@MaxLengthdecorators@nestjs/throttlerglobal 60/min; ChatController 10/min override@fastify/helmetregistered on Fastify app (CSP disabled for now)bodyLimit: 1_048_576; startup throws ifBETTER_AUTH_SECRETnot setTests
apps/gateway/src/__tests__/resource-ownership.test.tsapps/gateway/src/chat/__tests__/chat-security.test.tsGates
58ba99f3ebto0fe2cb79a7Code Review: APPROVED ✅
All 7 security fixes look solid.
assertOwner()helper clean and reused across all 4 controllers.validateSocketSession()properly converts Node headers, disconnects on null.ThrottlerGuardas APP_GUARD (global 60/min) + ChatController override (10/min). Helmet registered before routes. BETTER_AUTH_SECRET guard before listen(). DTOs correctly converted from interface to class with class-validator. Minor: tasks with no projectId/missionId throw ForbiddenException — conservative secure default, acceptable.Gates: typecheck ✅ lint ✅ format ✅
Ready for Merge Guard.
19a04e9b0dto85a25fd995