fix(security): reject invalid allowedOrigins at registration #274
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.60) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.60 · 217 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.322
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.060
Real PR Conversation Timeline
1 comments
"Review active on #274"
general
weight: 0.35
rozzilla
Problem
allowedOriginsis typedstring[] | '' | true, but nothing validated it at runtime. A single string reachedisOriginAllowed, whereallowed.includes(origin)turned intoString.prototype.includes, which is a substring match. WithallowedOrigins: 'https://acme.com', the originshttps://acme.co,https://acme.c,hand""all got past the DNS-rebinding check.Fix
src/index.ts: registration throws aTypeErrorunlessallowedOriginsisundefined,true,''or an array whose elements are all strings. A single string is rejected, not wrapped in an array, so the misconfiguration is reported instead of silently changing meaning.src/security.ts:isOriginAllowedreturnsfalsefor any non-array allow-list, so the substring path can't be reached even if the check is bypassed.test/allowed-origins-validation.test.ts: registration throws for a string, for an array containing a non-string and for other invalid shapes; valid shapes still register; the issue's repro origins now get 403.Breaking change
Registering with
allowedOriginsset to anything other thanundefined,true,'*'or a string array now throws. Before this change, such values were accepted and either matched by substring or crashed at request time. To fix it, wrap a single origin in an array.Overlaps with #240 (validate Origin by default), which touches
isOriginAllowedand the README Origin section. I kept this change small so a rebase is trivial: the validation lives insrc/index.tsand the tests are in a new file.Fixes #255
🤖 Generated with Claude Code
https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM