Skip to content

feat(hub): protect HTTPS session cookies - #380

Open
weastler wants to merge 4 commits into
build/hub/newfrom
weastler-hub-session-cookie-protection
Open

weastler wants to merge 4 commits into
build/hub/newfrom
weastler-hub-session-cookie-protection

Conversation

@weastler

@weastler weastler commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 22536438dd017b2fcba5c0b769521fe3251e9044

Dimension Assessment Rationale
Change confidence 9/10 ↑ Focused regression tests cover HTTPS startup, browser binding, session selection, and sign-out; the full Linux Hub unit and PostgreSQL suites and the installer suite passed.
↓ Browser enforcement and deployed HTTPS ingress were not exercised; the conventions review was not a security review.

Why

Hub should bind HTTPS sign-in sessions to the Hub host independently of where prototypes are hosted. This prepares the session boundary for future preview hosting changes without changing where previews can run today.

What changes

HTTPS sign-in sets a host-only Hub session cookie and uses a separate host-only browser binding while sign-in is in progress. Hub requires a configured trusted proxy chain before it starts with HTTPS sign-in enabled. Existing sessions still work for ordinary Hub use; private preview launch and confirmation require signing out and signing in again if your session predates the change. HTTP loopback sign-in is unchanged. Restart any in-progress HTTPS sign-in or sensitive authorization when upgrading. No database migration is needed.

Storybook screenshots

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@weastler
weastler requested review from a team and nshki as code owners November 25, 2026 21:46
Copilot AI adaptive review requested due to automatic review settings November 25, 2026 21:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical authentication issues block HTTPS callbacks under the default proxy configuration and allow sibling-host cookie injection to complete sign-in as the wrong user.

4 open issues
What changed in this PR

Strengthens Hub’s HTTPS session boundary ahead of future preview-hosting changes, while retaining legacy sessions for ordinary Hub use and HTTP development.

Changes:

  • Introduces host-only HTTPS session cookies and checks callback transport and host.
  • Updates session readers and cookie clearing; requires protected cookies for private-preview launch and confirmation.
  • Expands regression coverage and documents migration, ingress, and rollback requirements.
File Description
hub/​server/​routes/​private-preview/​index.ts Requires protected sessions for launch and confirmation.
hub/​server/​routes/​private-preview/​index.test.ts Covers protected sessions and legacy-session rejection.
hub/​server/​routes/​index.ts Passes configured origins to authentication callbacks.
hub/​server/​routes/​api/​workspace/​welcome/​patch/​index.ts Uses the shared session reader.
hub/​server/​routes/​api/​workspace/​get/​index.ts Supports protected workspace sessions.
hub/​server/​routes/​api/​settings/​github/​authorize-github-setup/​index.ts Supports protected setup sessions.
hub/​server/​routes/​api/​session-revocation/​authorizations/​continue/​post/​index.ts Clears both HTTPS session cookie names.
hub/​server/​routes/​api/​security-audits/​get/​index.ts Supports protected audit sessions.
hub/​server/​routes/​api/​review-comments/​read-review-session/​index.ts Updates review-session lookup.
hub/​server/​routes/​api/​review-comments/​create-review-realtime-access/​index.ts Updates WebSocket session authentication.
hub/​server/​routes/​api/​repositories/​templates/​index.ts Supports protected template-access sessions.
hub/​server/​routes/​api/​repositories/​show/​get/​index.ts Updates repository session lookup.
hub/​server/​routes/​api/​repositories/​prototypes/​show/​patch/​index.ts Updates prototype-edit session lookup.
hub/​server/​routes/​api/​repositories/​prototypes/​show/​get/​index.ts Updates prototype-view session lookup.
hub/​server/​routes/​api/​repositories/​prototypes/​review-comments/​get/​index.ts Updates review-comment authorization lookup.
hub/​server/​routes/​api/​repositories/​prototypes/​builds/​get/​index.ts Updates Build-list session lookup.
hub/​server/​routes/​api/​repositories/​prototypes/​builds/​access/​get/​index.ts Updates Build-access session lookup.
hub/​server/​routes/​api/​repositories/​prototype-management/​get/​index.ts Updates management session lookup.
hub/​server/​routes/​api/​repositories/​authors/​get/​index.ts Updates repository-user session lookup.
hub/​server/​routes/​api/​repositories/​analytics/​index.ts Updates analytics session lookup.
hub/​server/​routes/​api/​repositories/​analytics/​callback/​index.ts Updates analytics callback session lookup.
hub/​server/​routes/​api/​public-sharing/​settings/​patch/​index.ts Updates sharing-settings authorization lookup.
hub/​server/​routes/​api/​public-sharing/​settings/​get/​index.ts Updates sharing-settings session lookup.
hub/​server/​routes/​api/​public-sharing/​links/​post/​index.ts Updates share-link creation session lookup.
hub/​server/​routes/​api/​public-sharing/​links/​get/​index.ts Updates share-link listing session lookup.
hub/​server/​routes/​api/​public-sharing/​links/​delete/​index.ts Updates share-link deletion session lookup.
hub/​server/​routes/​api/​learnings/​read-learning-session/​index.ts Updates learning-session lookup.
hub/​server/​routes/​api/​learnings/​read-learning-session-digest/​index.ts Derives digests from the shared reader.
hub/​server/​routes/​api/​decision-model/​read-decision-model-session/​index.ts Updates decision-model session lookup.
hub/​server/​routes/​api/​copilot-connection/​read-session-digest/​index.ts Updates Copilot session-digest lookup.
hub/​server/​routes/​api/​canvas/​index.ts Updates canvas browser-session lookup.
hub/​server/​routes/​api/​auth/​session/​sign-out/​post/​index.ts Uses shared session reading and cookie clearing.
hub/​server/​routes/​api/​auth/​session/​get/​index.ts Restores protected or legacy sessions.
hub/​server/​routes/​api/​auth/​index.test.ts Covers issuance, precedence, callback checks, and sign-out.
hub/​server/​routes/​api/​auth/​callback/​get/​index.ts Validates HTTPS callbacks and issues protected cookies.
hub/​server/​routes/​api/​administrators/​read-administrator-session/​index.ts Updates administrator-session lookup.
hub/​server/​integrations/​express/​read-hub-session-cookie/​index.ts Adds protected-first session reading.
hub/​server/​integrations/​express/​read-cookie/​index.ts Adds optional fallback cookie lookup.
hub/​server/​integrations/​express/​hub-session-cookie-name/​index.ts Defines the protected cookie name.
hub/​server/​integrations/​express/​clear-hub-session-cookies/​index.ts Centralizes session cookie clearing.
hub/​server/​domains/​github-builds/​import-github-workflow-run/​index.db.test.ts Uses protected private-preview sessions.
hub/​server/​domains/​admission/​provider-evidence-ordering.db.test.ts Models trusted HTTPS proxy callbacks.
hub/​server/​create-app/​index.test.ts Covers protected workspace-session propagation.
hub/​docs/​build-previews.md Explains private-preview session migration.
hub/​docs/​authentication.md Documents cookie behavior, ingress, and rollback.

Review effort: Max (adaptive)

weastler and others added 3 commits November 25, 2026 17:23
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants