← Back to Pull requests

fix(security): reject invalid allowedOrigins at registration #274

Closed
unknown closed this pull request without merging on Oct 15, 2026 06:52 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 11:18 UTC
Author

Problem

allowedOrigins is typed string[] | '' | true, but nothing validated it at runtime. A single string reached isOriginAllowed, where allowed.includes(origin) turned into String.prototype.includes, which is a substring match. With allowedOrigins: 'https://acme.com', the origins https://acme.co, https://acme.c, h and "" all got past the DNS-rebinding check.

Fix

  • src/index.ts: registration throws a TypeError unless allowedOrigins is undefined, 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: isOriginAllowed returns false for any non-array allow-list, so the substring path can't be reached even if the check is bypassed.

  • README: documents the accepted shapes.

  • 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 allowedOrigins set to anything other than undefined, 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 isOriginAllowed and the README Origin section. I kept this change small so a rebase is trivial: the validation lives in src/index.ts and the tests are in a new file.

    Fixes #255

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM

    Diff: 217 lines (+162 / -55) across 2 files Reviewer: rozzilla Review duration: 2614m
    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
    0.60
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 59.9% (MEDIUM) · Higher = larger blast radius
    59.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.6% · Safe to merge
    23.6%