Add WebSocket rate limits and payload size limits (#338) - #405
Merged
dzekojohn4 merged 4 commits intoAug 31, 2026
Merged
Conversation
… oversized payloads Add per-user rate limiting and payload size validation to the multiplayer queue and in-app notifications modules to prevent abuse. - Introduce RateLimitGuard (in-memory sliding-window, per-IP) and @ratelimit decorator for configurable per-route throttling (429 with retryAfter header). - Apply rate limits: join 5/min, matchmaking 2/min, reads 30/min, notification create 10/min, system broadcast 5/min. - Enforce max field lengths: notification title 200 chars, message 2000 chars, username 100 chars, gameMode 50 chars. - Cap array sizes: opponents lists ≤10, batch mark-read ≤100. Closes UnityChainxx#338 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
… notifications Implement WebSocket gateways for the multiplayer queue and in-app notifications channels with per-socket rate limiting and payload size validation, addressing the core ask of UnityChainxx#338. - MultiplayerGateway (/multiplayer namespace): joinQueue 5/min, leaveQueue 10/min, getQueueStatus 30/min - NotificationsGateway (/notifications namespace): subscribe 5/min, sendNotification 10/min, broadcastNotification 3/min, getUnreadCount 30/min - WsRateLimitGuard: in-memory sliding-window throttler keyed by socket userId with periodic cleanup (5 min) - @WsRateLimit decorator for per-handler limits - All handlers validate payload size (8 KB max) and field lengths inline before touching the service layer Closes UnityChainxx#338 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@eulami Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
dzekojohn4
approved these changes
Aug 31, 2026
dzekojohn4
left a comment
Contributor
There was a problem hiding this comment.
Looks good, merging in.
dzekojohn4
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #338