fix(security): patch critical/high defects from code audit#594
Merged
Conversation
- Move proxy_api_key check before active===0 early-return in chat route (auth bypass) - Use constant-time comparison for API key validation (timing side-channel) - Parse Bearer prefix with case-insensitive regex (RFC 7235 compliance) - Cap compact handler retries at 8 (prevent infinite loop) - Add _destroyed flag to RefreshScheduler semaphore (prevent negative count after destroy)
c6d17f2 to
8d78737
Compare
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
proxy_api_keyvalidation beforeactive === 0early-return in chat route, closing a gate where unauthenticated requests could reach the proxy handler===withcrypto.timingSafeEqualinvalidateProxyApiKey/^bearer\s+/iregex per RFC 7235_destroyedflag toRefreshSchedulerto prevent negative_runningafterdestroy()Also includes prior commit: log codex request reasoning in egress details.
Test plan
npx tsc --noEmit— zero errorsnpm test— 230 files, 2274 tests passbearerprefix → should authenticate