Repository navigation
fix(sso): close role-guard bypasses and harden the image build - #3
Merged
Merged
Conversation
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.
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
PR ReviewThe next push will retry automatically. |
…ardening # Conflicts: # sso/apply.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
POST /clickhouse-proxy/TESTreached the admin-only connection test as a viewer, and/CLICKHOUSE-PROXY/skipped the forcedreadonly=2./alerts/:id/silencedor/webhooks) acted as the victim.GET /meandGET /teamreturned the teamapiKey, which lets anyone push telemetry and trigger alerts.@hyperdx/app@2.42.0pointing 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.main(chore(deps): bump next from 16.3.8 to 16.4.1 ClickHouse/ClickStack#3460) but not in a release.packages: write;workflow_dispatchinput interpolated into shell.What changed
proxyAuthRoles.ts: lowercase the path once and match everything against it; reject non-safe browser requests whoseSec-Fetch-Site(elseOriginvsFRONTEND_URL) is cross-site; stripapiKey/hookIdfromGET /meandGET /teamfor non-admins; 404 for password/register/invite routes.apply.sh: validate the tag, fetch it from hyperdxio/hyperdx intorefs/sso-upstream/, cherry-pickUPSTREAM_PATCHESthe tag lacks (currently the Next 16.4.1 bump).sso-image.yml: actions pinned to commit SHAs; inputs passed viaenvand validated.Testing
proxyAuthRoles.test.ts: 64 tests, new cases for case variants, cross-site writes, key stripping and disabled routes.tsc --noEmitclean; all 533 MCP + middleware unit tests pass.apply.shend to end: builds upstream commitcf00ae53f(not the fork tag),nextresolves to 16.4.1,yarn install --immutablepasses, an injected tag string is rejected.Needs infra (infra-terraform)
FRONTEND_URL=https://click.topia.ioon the HyperDX container (drives theOrigincheck and the cookiesecureflag).cookie_samesite = "lax".