Skip to content

fix(security): patch critical/high defects from code audit#594

Merged
icebear0828 merged 1 commit into
devfrom
fix/egress-log-request-details
May 25, 2026
Merged

fix(security): patch critical/high defects from code audit#594
icebear0828 merged 1 commit into
devfrom
fix/egress-log-request-details

Conversation

@icebear0828
Copy link
Copy Markdown
Owner

Summary

  • Auth bypass — move proxy_api_key validation before active === 0 early-return in chat route, closing a gate where unauthenticated requests could reach the proxy handler
  • Timing side-channel — replace === with crypto.timingSafeEqual in validateProxyApiKey
  • Bearer case-insensitivity — use /^bearer\s+/i regex per RFC 7235
  • Compact infinite loop — cap retry attempts at 8 with 502 fallback
  • Semaphore destroy race — add _destroyed flag to RefreshScheduler to prevent negative _running after destroy()

Also includes prior commit: log codex request reasoning in egress details.

Test plan

  • npx tsc --noEmit — zero errors
  • npm test — 230 files, 2274 tests pass
  • Manual: send request with lowercase bearer prefix → should authenticate
  • Manual: verify compact endpoint returns 502 after exhausting retries

- 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)
@icebear0828 icebear0828 force-pushed the fix/egress-log-request-details branch from c6d17f2 to 8d78737 Compare May 25, 2026 11:00
@icebear0828 icebear0828 merged commit 94a9649 into dev May 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant