Fix bounded rate-limit guard and validation - #1693
Merged
Baskarayelu merged 1 commit intoAug 30, 2026
Merged
Conversation
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 #1680
PR Title
Fix bounded rate-limit guard and validation for admin / operational surfaces
Summary
This change hardens the API’s resource and rate-limit boundary by enforcing bounded values before expensive throttling work runs. It prevents malformed or adversarial configuration from creating unbounded quotas or excessive window sizes, while preserving normal behavior for valid traffic.
What changed
Why this matters
This closes a production-grade gap in operational safety: unbounded or malformed rate-limit inputs can otherwise defeat the guardrail, degrade service quality, or allow repeated work to exhaust resources. The fix ensures deterministic, reviewable behavior under normal, invalid, repeated, and burst traffic conditions.
Scope
This is intentionally narrow and focused on the rate-limit / resource boundary. It does not include unrelated refactors or broad dependency changes.
Validation
I validated the affected rate-limit and guard behavior with:
Result:
I also ran a repo TypeScript check:
That still fails due to pre-existing unrelated TypeScript errors in:
Those issues are outside the scope of this fix.
Compatibility
This is backward-compatible for valid settings. The only behavior change is that invalid or excessive rate-limit values are now safely clamped instead of being permitted to create unsafe or unbounded limits.
Notes
This patch preserves the public behavior for normal traffic while providing clear, deterministic failure behavior under invalid or adversarial conditions.
Shorter GitHub-ready version
Title:
Fix bounded rate-limit guard and validation
Body:
This PR hardens the API’s resource and rate-limit boundary by clamping invalid or oversized config and route-level inputs before they reach the throttling logic.
Changes
Why
Unbounded rate-limit configuration can allow malformed or adversarial input to bypass protection or exhaust backend resources. This fix ensures predictable, safe behavior under normal, invalid, and burst conditions.
Validation
Passed:
node .\node_modules\jest\bin\jest.js --runInBand --ci --verbose src/rate-limit/rate-limit.service.spec.ts src/common/guards/custom-throttler.guard.spec.tsResult:
Known unrelated blocker: