GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — id(web): Origin check ignores the port — a different localhost port passes as same-origin (CSRF/CSWSH gap in security.rs) · Issue #814 · developing-today/code

id(web): Origin check ignores the port — a different localhost port passes as same-origin (CSRF/CSWSH gap in security.rs) #814

New issue
Copy link
New issue
Copy link
Closed
#823
Closed
id(web): Origin check ignores the port — a different localhost port passes as same-origin (CSRF/CSWSH gap in security.rs)#814
#823
Copy link
Assignees
dezren39
Labels
app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/securitySecurity issue or security hardening

Description

@dezren39
dezren39
opened on Oct 24, 2026
Issue body actions

Problem

The id web UI's Origin check (pkgs/id/src/web/security.rs) compares only the host of the Origin header against the host of the Host header — the port is stripped from both sides before comparison, so an origin on a different port of the same host passes as "same-origin".

This defeats the layer the module docs say it provides (security.rs:12-15): defeating cross-site request forgery and cross-site WebSocket hijacking for browser requests. An origin is scheme + host + port: a page served from http://localhost:9999 (any other local web app, dev server, or attacker page proxied/served on another local port) is a different origin from the id UI on http://localhost:3000, but the guard treats them as the same. WebSocket handshakes carry no CORS preflight, so the Origin check is the only browser-side defence for the /ws/* routes when no token is configured (the default loopback setup relies on exactly these host/origin layers).

Evidence (verified on main 1161bcff)

  • security.rs:73-83 — host_only() strips an optional :port (and lower-cases) from a Host/Origin authority: host_only("localhost:9999") == host_only("localhost:3000") == "localhost".
  • security.rs:138-145 — the guard's same-origin test is exactly that comparison:
    let same = origin_authority(origin).is_some_and(|a| host_only(a) == host_only(&host_header));
    So a request with Host: localhost:3000 and Origin: http://localhost:9999 evaluates same == true and is not refused.
  • The existing test same_origin_is_allowed_cross_origin_is_not (security.rs:278) only exercises a same-port origin (http://localhost:3000 vs Host localhost:3000) and a different-host origin (https://evil.example); no test covers a different-port origin.
  • No other layer compensates: grep -rn Origin pkgs/id/src/web shows this guard is the only Origin check in the web stack.

Repro (verified by running the guard): a test added to the security tests in a scratch worktree driving guard with Host: localhost:3000 and Origin: http://localhost:9999, asserting the current behaviour, passed on main 1161bcff — i.e. the different-port origin was answered 200 OK where a true same-origin check would refuse with 403. Full run: cargo test --features web --lib web::security:: → 12 passed, 0 failed (11 pre-existing + the repro case).

Why it matters

  • The loopback default has no token, so layers 2+3 (host allow-list + origin check) are the whole browser-attack defence. Layer 3 currently does not distinguish local origins, which is precisely the neighbour it exists to distinguish: other content reachable in the user's browser on another local port.
  • The collab/world WebSocket routes are state-changing and long-lived; a cross-site WebSocket from a different local origin inherits the user's ambient access to the UI.

Suggested fix

Compare the full authority (host and port) for the Origin check, while keeping the host allow-list check host-only as it is today:

  • Keep host_only() for the allow-list comparison (step 2).
  • For step 3, compare a port-preserving normalised authority (lower-cased host, explicit port when present; IPv6 brackets handled like host_only does) of origin_authority(origin) against the Host header authority.
  • Decide and document the no-port cases: an Origin with no explicit port vs a Host with an explicit port (e.g. behind a proxy / default-port serving) — treat missing port as the scheme default, or refuse; either is defensible, but it must be a deliberate, tested choice, not an accident of stripping.

Acceptance criteria

  • Request with Host: localhost:3000 and Origin: http://localhost:9999 (and the IPv4/[::1] equivalents) is refused with 403.
  • Same-authority origins (same host, same port, any case) still pass; different-host origins still 403; Origin: null still refused.
  • New regression tests cover different-port origin refusal and same-port acceptance; existing security tests pass (cargo test --features web web::security).
  • Module docs updated so the stated Origin guarantee matches the implemented comparison.

Activity

  1. github-actions
    assigned
    dezren39
    on Oct 24, 2026
  2. dezren39
    closed this as completedin #823on Oct 25, 2026
  3. dezren39
    added a commit that references this issue on Nov 12, 2026

    fix(id): reject Origin scheme mismatches in the web same-origin guard (…

    22fee7c
  4. developing-today-fleet commented on Nov 24, 2026

    @developing-today-fleet
    developing-today-fleetBot
    on Nov 24, 2026 – with developing.today fleet
    Contributor
    More actions

    AUDIT-7 Lane 2 slice 3 — closing evidence. Verified against the issue body and merged implementation PR(s):

    • PR #823 — fix(id-web): Origin check compares host and port (fixes #814) (merged 2026-10-25)

    The issue had zero comments in the fresh pre-action read; this comment records the missing close evidence.

  5. dezren39
    added
    kind/securitySecurity issue or security hardening
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/securitySecurity issue or security hardening

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.