← Back to Pull requests

feat(http): answer browsers only by the node's own names; Secure from requestOrigin (W39, D1361–D1363) #243

Open
unknown opened this pull request with 320 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 23, 2026 11:01 UTC
Author

W39 slice 1 (security.md PR 6a). Implements D1361–D1363.

  • D1361 — the W39 threat model, written before the code: DNS rebinding, forged X-Forwarded-Proto, shell access through terminals.write, one connection holding the node's memory, stolen bearer tokens, MCP clients granted too much, secrets at rest.

  • D1362 — jhin.http refuses a browser's request (Origin or Sec-Fetch-Site) for a host the node does not answer to with 403, before any route or upgrade (a DNS rebinding page). Answered: every IP address, localhost/.localhost, the machine's host name (and .local), .ts.net (Tailscale Serve), the mesh's advertised hosts (http.server 1.4 allowHost, additive and optional) and jhin.http.allowedHosts (name, .example.com, *). Requests from trustProxy peers and non-browsers (CLI, nodes, MCP clients; Node's fetch sends Sec-Fetch-Mode, so that header does not count) are not checked, so existing pairing (W33), jhin client, mesh links and MCP clients keep working.

  • D1363 — the session cookie's Secure follows requestOrigin (TLS, or X-Forwarded-Proto: https only from a trusted or loopback peer).
  • Behaviour change, documented in D1362: a browser opening the node by an unlisted LAN name (nas.lan) gets 403 with "Add it to jhin.http.allowedHosts."

    Evidence

    $ vp test run plugins/http/test/allowed-hosts.test.ts plugins/mesh/test/allowed-hosts.test.ts
     Tests  5 passed (5)   # http: rebound name refused for GET/Sec-Fetch/upgrade, non-browser answered,
                           # addresses/loopback/machine/ts.net answered, allowedHosts + allowHost until disposed,
                           # "*" and trusted proxy; mesh: advertised host answered, another refused
     Tests  1 passed (1)
    $ vp test run plugins/transport-ws/test/transport.test.ts plugins/mesh/test
     Test Files  4 passed (4)
          Tests  61 passed (61)   # incl. "marks the cookie Secure only when the request came over HTTPS (D1363)"
    $ vp run --filter @jhin/plugin-http --filter @jhin/plugin-mesh --filter @jhin/plugin-auth-token --filter @jhin/http-api typecheck
    vp run: 4/4 successful.
    $ pnpm verify --affected
      ✓ check ✓ typecheck ✓ knip ✓ public-ids ✓ pack   ✗ unit ✗ e2e
    

    The local unit failures are unrelated and reproduce alone: Chromium/preview and source-control tests timing out at 5 s under the machine's load, and apps/jhin/test/cli.test.ts reading Node 22's ExperimentalWarning: SQLite (local Node is 22; CI runs 24). CI runs the full suite.

    🤖 Generated with Claude Code

    Diff: 320 lines (+240 / -80) across 4 files Reviewer: claude[bot] Review duration: 7m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.46)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 320 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 99% · Reviewer familiarity: 35%
    46%
    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.345
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #243"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.5% reviewed
    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: 41.9% (MEDIUM) · Higher = larger blast radius
    41.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: 46.5% · Lower = rushed or shallow review
    46.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: 22.4% · Safe to merge
    22.4%
    Repository