fix(keycloak): bind ReadOnly permission to explicit resources to prevent multi-team isolation bypass - #71313
Open
waterWang wants to merge 1 commit into
Open
Conversation
…ent multi-team isolation bypass
**Problem:** The scope-based permission is created with
(unbound), which matches *every* resource carrying
GET/LIST/MENU scopes in Keycloak — including per-team resources like
. This shadows the correctly built aggregate
permissions and grants read access on role alone, bypassing team isolation.
**Fix (4 changes):**
1. **Bind to explicit global resources** — both in the
(non-teams and teams) and in
, so the permission covers only
non-team resources (Dag, Connection, Pool, Variable, Team, Asset,
AssetAlias, Configuration) instead of matching everything.
2. **Expand to all team-scoped resources** — previously
only covered and . Now covers all
(Connection, Dag, Pool, Team, Variable),
consistent with the permission.
3. **Expand global permission to include global resources** —
under , the global Admin permission now covers both team and
global resources, so Admin users can interact with shared (teamless)
resources as documented.
4. **Set explicitly in
for both and permissions** — replaces
with the full list of known resources, preventing unbound-scope leakage.
Fixes: apache#71277
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.
Problem
The
ReadOnlyscope-based permission is created withresources: [](unbound), which matches every resource carrying GET/LIST/MENU scopes in Keycloak — including per-team resources likeDag:team-b. This shadows the correctly builtReadOnly-{team}aggregate permissions and grants read access on role alone, bypassing team isolation.Fix (4 changes)
Bind
ReadOnlyto explicit global resources — both in_get_permissions_to_create(non-teams and teams) and in_attach_default_role_permissions, so the permission covers only non-team resources (Dag, Connection, Pool, Variable, Team, Asset, AssetAlias, Configuration) instead of matching everything.Expand
ReadOnly-{team}to all team-scoped resources — previously only coveredDag:{team}andTeam:{team}. Now covers allTEAM_SCOPED_RESOURCE_NAMES(Connection, Dag, Pool, Team, Variable), consistent with theAdmin-{team}permission.Expand
Adminglobal permission to include global resources — under--teams, the global Admin permission now covers both team and global resources, so Admin users can interact with shared (teamless) resources as documented.Set
resource_namesexplicitly in_attach_default_role_permissionsfor bothReadOnlyandAdminpermissions — replacesresource_names=[]with the full list of known resources, preventing unbound-scope leakage.Test
Modified tests in
test_commands.pyto reflect the new resource bindings.Fixes #71277