[codex] Validate CORS allowlist origins#224
Open
pq198363-ops wants to merge 1 commit into
Open
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 #97
Summary
CORS_ALLOWED_ORIGINSinto normalizedhttp(s)://host[:port]origins.*configuration at startup so deployments list trusted origins explicitly.Vary: Originon Origin-bearing requests and never reflect unlisted origins.Threat model
The server should only reflect origins that normalize to an explicit configured allowlist entry. A hostile Origin header, malformed config entry, or wildcard misconfiguration should not create arbitrary origin reflection or an unsafe wildcard/credentials posture.
RED/GREEN evidence
Vary: Origin, malformed entries were not logged, and wildcard config did not fail startup.Verification
npm run buildpassed.$env:NODE_ENV='test'; node --test dist/cors.test.jspassed 4 tests.npx prettier --check README.md src/middleware/index.ts src/cors.test.tspassed.npm run lintpassed.dist/, rebuilt withnpm run build, then$env:NODE_ENV='test'; node --test dist/*.test.js dist/**/*.test.jspassed 93 tests across 11 suites.git diff --cached --checkpassed before commit.Note:
npm testuses POSIX-styleNODE_ENV=test, so on Windows PowerShell I used the equivalent$env:NODE_ENV='test'; node --test ...commands.