Skip to content

fix(security): confine guest tokens with ROLE_TOKEN_PRINCIPAL and real-user fallback rules (#2343) - #2382

Merged
juanresendiz813 merged 5 commits into
developmentfrom
fix/2343-guest-authority
Nov 18, 2026
Merged

juanresendiz813 merged 5 commits into
developmentfrom
fix/2343-guest-authority

Conversation

@buggtb

@buggtb buggtb commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Guest identities minted for embed, share and SCIM tokens now carry a distinct ROLE_TOKEN_PRINCIPAL authority, 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-anonymous Authentication, including the PreAuthenticatedAuthenticationToken guests. The /embed/**, /share/**, /rest/**, /json/** and /** catch-alls (and the /xmla chain) 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 by EmbedAuthFilter, ShareTokenAuthFilter and ScimAuthFilter next to their specific role.
  • applicationContext-saiku.xml: every isFullyAuthenticated() rule becomes isFullyAuthenticated() and !hasRole('TOKEN_PRINCIPAL'); the guest-admitting rules become hasRole('X_GUEST') or (isFullyAuthenticated() and !hasRole('TOKEN_PRINCIPAL')). I chose the negative form (as the issue prefers) rather than hasRole('USER') so external/OAuth/SCIM-provisioned users who do not carry ROLE_USER keep working.
  • /embed/ai/** has no rule of its own, so an ai guest 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.
  • XML comments rewritten to describe the real model.

Overlap: PR for #2342 also edits EmbedAuthFilter, ShareTokenAuthFilter and ScimAuthFilter (path helper); different lines, trivial rebase on whichever merges second.

Test plan

  • acceptance/2343/check.mjs red on base, green on head (structural: filters add the marker, no bare isFullyAuthenticated() rule left, test ships)
  • SpringUrlRulesGuestExclusionTest evaluates the real XML rules (first-match, WebExpressionAuthorizationManager) for embed guest, embed author, share guest, SCIM principal, real user and anonymous
  • mvn -pl saiku-core/saiku-web -am test -Dtest='SpringUrlRulesGuestExclusionTest,EmbedAuthFilter*Test,ShareTokenAuthFilter*Test,ScimAuthFilter*Test,SaikuCsrf*Test' passes; mvn spotless:apply
  • Launcher ITs (UrlGateHardeningIT probe table) not run locally; not added in this PR

Closes #2343

🤖 Generated with Claude Code

buggtb and others added 2 commits November 12, 2026 17:11
…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>
@buggtb buggtb added the security Created by Hive for agent-filed issue provenance label Nov 12, 2026
@github-actions github-actions Bot added risk/high Change risk tier: high (see docs/risk-tiers.md) area/web labels Nov 12, 2026
@github-actions

Copy link
Copy Markdown

Semantic model diff

Semantic model diff

No model changes and no broken references.

saiku#1434 · reproduce locally with saiku model diff

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

CI feedback

passing · 825a8d7
Generated 2026-11-18T22:39:11.208Z. Machine-readable copy: ci-feedback.json (schema v1, see docs/ci-feedback.md) - artifact on this run.

Nothing to fix: every check in this commit concluded successfully.

@juanresendiz813 juanresendiz813 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.

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

  1. blocking · Build · acceptance/2343/spec.json:4 uses "kind": "command"; the validator (.github/scripts/acceptance-spec.mjs:28) accepts only api and ui, so ci / flake-policy tests fails with acceptance/2343: "kind" must be one of api, ui. Not a flake.
    Would accept: "kind": "ui" (the convention for a command array, docs/acceptance-specs.md:245), in a commit that touches only that file. Your check.mjs already 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 and SpringUrlRulesGuestExclusionTest.java:127 say 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 the ai embed is meant to work; if so, an explicit /rest/saiku/api/embed/ai/** rule admitting EMBED_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 in TokenPrincipals saying the marker is mandatory for any new token filter would help.
  • Merge note: textual conflict with #2375 in EmbedAuthFilter.java, ScimAuthFilter.java and ShareTokenAuthFilter.java (adjacent import lines only); keep both imports.

🤖 Generated with Claude Code

@juanresendiz813 juanresendiz813 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.

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>
@juanresendiz813
juanresendiz813 added this pull request to the merge queue Nov 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 18, 2026
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>
@juanresendiz813
juanresendiz813 added this pull request to the merge queue Nov 18, 2026
Merged via the queue into development with commit 5f18583 Nov 18, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/web risk/high Change risk tier: high (see docs/risk-tiers.md) security Created by Hive for agent-filed issue provenance

Projects

None yet

2 participants