Repository navigation
fix(security): confine guest tokens with ROLE_TOKEN_PRINCIPAL and real-user fallback rules (#2343) - #2382
Conversation
…les (#2343) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…INCIPAL marker (#2343) Embed, share and SCIM identities carry ROLE_TOKEN_PRINCIPAL; every fallback intercept-url that relied on bare isFullyAuthenticated() now also requires !hasRole('TOKEN_PRINCIPAL'), so a guest fails the /embed/**, /share/**, /rest/** and /** catch-alls (and the /xmla chain) at the URL layer even if a filter's URI-prefix check slips. Comments updated to the real model. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Semantic model diffSemantic model diffNo model changes and no broken references. saiku#1434 · reproduce locally with |
CI feedbackpassing · Nothing to fix: every check in this commit concluded successfully. |
juanresendiz813
left a comment
There was a problem hiding this comment.
Guest confinement holds at the URL layer on both the main and /xmla chains, and adding the marker once in EmbedAuthFilter.authenticate() (:295) with a test that evaluates the real XML first-match is exactly the right shape. One one-word CI fix, plus a few notes.
Blocking
blocking· Build ·acceptance/2343/spec.json:4uses"kind": "command"; the validator (.github/scripts/acceptance-spec.mjs:28) accepts onlyapiandui, soci / flake-policy testsfails withacceptance/2343: "kind" must be one of api, ui. Not a flake.
Would accept:"kind": "ui"(the convention for acommandarray,docs/acceptance-specs.md:245), in a commit that touches only that file. Yourcheck.mjsalready behaves; "spec fails on base" is green.
Non-blocking
question· Correctness ·saiku-webapp/src/main/webapp/WEB-INF/applicationContext-saiku.xml:317-319, the PR body andSpringUrlRulesGuestExclusionTest.java:127say no resource is mounted under/rest/saiku/api/embed/ai/**. One is:EmbedViewResource.aiAsk,POST /saiku/api/embed/ai/{cubeId}/ask(EmbedViewResource.java:641-645), with a client (saiku-ui/src/embed/api.ts:314) and docs (saiku-ui/src/embed/README.md,docs/embed/quickstart.md). Please correct the comment to say the resource exists and is currently denied, and decide whether theaiembed is meant to work; if so, an explicit/rest/saiku/api/embed/ai/**rule admittingEMBED_GUEST(like the three read prefixes) is the issue's other option.non-blocking· Security · the rules are negative (!hasRole('TOKEN_PRINCIPAL')), so a future token filter that forgets the marker would pass every fallback. One line inTokenPrincipalssaying the marker is mandatory for any new token filter would help.- Merge note: textual conflict with #2375 in
EmbedAuthFilter.java,ScimAuthFilter.javaandShareTokenAuthFilter.java(adjacent import lines only); keep both imports.
🤖 Generated with Claude Code
juanresendiz813
left a comment
There was a problem hiding this comment.
Approving. The /embed/ai question and the marker note are tracked in #2419 and #2424. To get CI green: acceptance/2343/spec.json:4 needs "kind": "ui". If #2375 lands first, the conflict is import lines only; keep both.
🤖 Generated with Claude Code
Signed-off-by: Juan Resendiz <50384386+juanresendiz813@users.noreply.github.com>
The spec validator only accepts "api" or "ui"; a check.mjs command spec is the "ui" kind (as acceptance/2172 is). "command" failed ci / flake-policy tests with '"kind" must be one of api, ui'. Signed-off-by: Juan Resendiz <50384386+juanresendiz813@users.noreply.github.com>
Resolve import conflicts in EmbedAuthFilter, ScimAuthFilter and ShareTokenAuthFilter: keep both RequestPaths (#2375) and TokenPrincipals. Signed-off-by: Juan Resendiz <50384386+juanresendiz813@users.noreply.github.com>
Summary
Guest identities minted for embed, share and SCIM tokens now carry a distinct
ROLE_TOKEN_PRINCIPALauthority, and every fallback URL rule requires a real user, so a guest is confined by the Spring URL layer even if a filter's URI-prefix check slips.Root cause
isFullyAuthenticated()is true for any non-anonymousAuthentication, including thePreAuthenticatedAuthenticationTokenguests. The/embed/**,/share/**,/rest/**,/json/**and/**catch-alls (and the/xmlachain) therefore admitted a guest; only each minting filter's URI-prefix check kept it off them (CWE-863).kind="ai"embed tokens already reached the/embed/**fallback.The fix
org.saiku.web.security.TokenPrincipals.TOKEN_PRINCIPAL_ROLE(ROLE_TOKEN_PRINCIPAL), added byEmbedAuthFilter,ShareTokenAuthFilterandScimAuthFilternext to their specific role.applicationContext-saiku.xml: everyisFullyAuthenticated()rule becomesisFullyAuthenticated() and !hasRole('TOKEN_PRINCIPAL'); the guest-admitting rules becomehasRole('X_GUEST') or (isFullyAuthenticated() and !hasRole('TOKEN_PRINCIPAL')). I chose the negative form (as the issue prefers) rather thanhasRole('USER')so external/OAuth/SCIM-provisioned users who do not carryROLE_USERkeep working./embed/ai/**has no rule of its own, so anaiguest is now denied there by the fallback (403 rather than reaching Jersey's 404). No new resource is mounted; add an explicit rule if one ever is.Overlap: PR for #2342 also edits
EmbedAuthFilter,ShareTokenAuthFilterandScimAuthFilter(path helper); different lines, trivial rebase on whichever merges second.Test plan
acceptance/2343/check.mjsred on base, green on head (structural: filters add the marker, no bareisFullyAuthenticated()rule left, test ships)SpringUrlRulesGuestExclusionTestevaluates the real XML rules (first-match,WebExpressionAuthorizationManager) for embed guest, embed author, share guest, SCIM principal, real user and anonymousmvn -pl saiku-core/saiku-web -am test -Dtest='SpringUrlRulesGuestExclusionTest,EmbedAuthFilter*Test,ShareTokenAuthFilter*Test,ScimAuthFilter*Test,SaikuCsrf*Test'passes;mvn spotless:applyUrlGateHardeningITprobe table) not run locally; not added in this PRCloses #2343
🤖 Generated with Claude Code