Skip to content

fix(sso): close role-guard bypasses and harden the image build - #3

Merged
jplorier merged 2 commits into
mainfrom
claude/sso-security-hardening
Oct 29, 2026
Merged

jplorier merged 2 commits into
mainfrom
claude/sso-security-hardening

Conversation

@jplorier

@jplorier jplorier commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Fixes the overlay and build-pipeline findings from a security review of the 2.42.0 SSO build. Header spoofing and access-key roles are tracked separately and not touched here.

Why

  • Viewer → admin via letter case (reproduced). Express routes case-insensitively; the role guard did not. POST /clickhouse-proxy/TEST reached the admin-only connection test as a viewer, and /CLICKHOUSE-PROXY/ skipped the forced readonly=2.
  • CSRF. The oauth2-proxy cookie alone authenticates a request, so a form posted from another site (e.g. to /alerts/:id/silenced or /webhooks) acted as the victim.
  • Ingestion key exposed to every role. GET /me and GET /team returned the team apiKey, which lets anyone push telemetry and trigger alerts.
  • Password login / registration / invite setup stayed mounted alongside SSO.
  • Wrong code could be built. The inherited upstream Release workflow created a fork tag @hyperdx/app@2.42.0 pointing at an SSO commit, which is why the PR feat(sso): three-tier roles with access-key role association #2 image build fails (would clobber existing tag). Had the fetch not failed, the image would have been built from the wrong commit under the right version name.
  • Next.js 16.3.8 in 2.42.0 is inside the range of the 16.4.1 RCE advisories; upstream has the bump on main (chore(deps): bump next from 16.3.8 to 16.4.1 ClickHouse/ClickStack#3460) but not in a release.
  • CI hardening: actions pinned by tag in a job with packages: write; workflow_dispatch input interpolated into shell.

What changed

  • proxyAuthRoles.ts: lowercase the path once and match everything against it; reject non-safe browser requests whose Sec-Fetch-Site (else Origin vs FRONTEND_URL) is cross-site; strip apiKey/hookId from GET /me and GET /team for non-admins; 404 for password/register/invite routes.
  • apply.sh: validate the tag, fetch it from hyperdxio/hyperdx into refs/sso-upstream/, cherry-pick UPSTREAM_PATCHES the tag lacks (currently the Next 16.4.1 bump).
  • sso-image.yml: actions pinned to commit SHAs; inputs passed via env and validated.

Testing

  • proxyAuthRoles.test.ts: 64 tests, new cases for case variants, cross-site writes, key stripping and disabled routes.
  • On the integrated 2.42.0 tree: tsc --noEmit clean; all 533 MCP + middleware unit tests pass.
  • apply.sh end to end: builds upstream commit cf00ae53f (not the fork tag), next resolves to 16.4.1, yarn install --immutable passes, an injected tag string is rejected.
  • Not run: the Docker image build itself (CI will on merge).

Needs infra (infra-terraform)

  • FRONTEND_URL=https://click.topia.io on the HyperDX container (drives the Origin check and the cookie secure flag).
  • oauth2-proxy cookie_samesite = "lax".
  • NetworkPolicy restricting HyperDX egress (webhook SSRF is an upstream bug, reported privately).

A security review of the 2.42.0 SSO build found issues in the overlay and
its build pipeline:

- Role guard: Express routes case-insensitively but the guard matched
  case-sensitively, so a viewer reached admin-only routes via e.g.
  POST /clickhouse-proxy/TEST and skipped the forced readonly=2. Paths are
  now lowercased before every check.
- CSRF: the oauth2-proxy cookie alone authenticates, so cross-site form
  posts acted as the victim. Browser writes from another site are rejected
  (Sec-Fetch-Site, else Origin vs FRONTEND_URL).
- The team ingestion key (apiKey, hookId) is stripped from GET /me and
  GET /team for non-admins; it lets anyone write telemetry.
- Password login, registration and invite setup return 404 under proxy auth.
- apply.sh fetches the upstream tag into refs/sso-upstream/ so same-named
  fork tags (created by the inherited release workflow) are never built,
  validates the tag, and cherry-picks upstream's Next 16.4.1 bump, which
  fixes RCE advisories not yet in a release.
- sso-image.yml pins actions to commit SHAs and passes the dispatch input
  through env instead of interpolating it into shell.
@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Oct 29, 2026
@github-actions

Copy link
Copy Markdown

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 2
  • Production lines changed: 126 (+ 90 in test files, excluded from tier calculation)
  • Branch: claude/sso-security-hardening
  • Author: jplorier

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

Copy link
Copy Markdown

PR Review

⚠️ The review did not complete: reviewer produced no structured output.

The next push will retry automatically.

@jplorier
jplorier merged commit 3db5174 into main Oct 29, 2026
@jplorier
jplorier deleted the claude/sso-security-hardening branch October 29, 2026 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant