Repository navigation
fix(auth): fail fast on missing CAPTCHA secret and harden rate-limit IP trust - #1300
Merged
nanaf6203-bit merged 1 commit intoSep 23, 2026
Merged
Conversation
|
@monique-7arch 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! 🚀 |
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.
Summary
Two authentication/rate-limiting hardening fixes for assigned issues.
1. Fail fast on missing CAPTCHA configuration (#1194)
src/utils/validate-env.ts: boot-time validation now requiresRECAPTCHA_SECRETwhenever CAPTCHA is enabled (the default; onlyCAPTCHA_BYPASS=truedisables it). A missing secret aborts boot with a clear fatal message instead of surfacing as an opaque 500 during login.src/auth/auth.service.ts:verifyCaptchanow throws a stableServiceUnavailableException(CAPTCHA_SERVICE_UNAVAILABLE) instead of a bareErrorfor a missing secret..env.example: documented the new requirement.test/unit/validate-env.spec.tsandsrc/auth/auth.service.captcha.spec.ts.2. Trusted reverse-proxy handling for rate-limit client IPs (#1195)
src/auth/guards/rate-limit.guard.ts:x-forwarded-foris no longer trusted unconditionally. It is only consulted whenTRUST_PROXYis configured; entries are sanitised (sanitizeIpEntry) and the derived IP is SHA-256 hashed before use as a rate-limit key, so a spoofed or malformed header can never rotate the per-IP buckets.src/main.ts:trust proxyis set fromTRUST_PROXYenv (NestExpressApplication), off by default.src/auth/rate-limit.guard.spec.tsfor spoofing/malformed-header cases.Closes #1194
Closes #1195
Closes #1196
Closes #1197