Skip to content

fix(keycloak): bind ReadOnly permission to explicit resources to prevent multi-team isolation bypass - #71313

Open
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/readonly-permission-team-resources
Open

fix(keycloak): bind ReadOnly permission to explicit resources to prevent multi-team isolation bypass#71313
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/readonly-permission-team-resources

Conversation

@waterWang

Copy link
Copy Markdown

Problem

The ReadOnly scope-based permission is created with resources: [] (unbound), which matches every resource carrying GET/LIST/MENU scopes in Keycloak — including per-team resources like Dag:team-b. This shadows the correctly built ReadOnly-{team} aggregate permissions and grants read access on role alone, bypassing team isolation.

Fix (4 changes)

  1. Bind ReadOnly to 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.

  2. Expand ReadOnly-{team} to all team-scoped resources — previously only covered Dag:{team} and Team:{team}. Now covers all TEAM_SCOPED_RESOURCE_NAMES (Connection, Dag, Pool, Team, Variable), consistent with the Admin-{team} permission.

  3. Expand Admin global 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.

  4. Set resource_names explicitly in _attach_default_role_permissions for both ReadOnly and Admin permissions — replaces resource_names=[] with the full list of known resources, preventing unbound-scope leakage.

Test

Modified tests in test_commands.py to reflect the new resource bindings.

Fixes #71277

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-Team: list endpoints return resources from all teams regardless of user's team

1 participant