Skip to content

fix(rbac): only Master Admin can confer a built-in role through inheritance - #91

Open
lorenzocorallo wants to merge 1 commit into
mainfrom
fix/rbac-builtin-role-inheritance
Open

lorenzocorallo wants to merge 1 commit into
mainfrom
fix/rbac-builtin-role-inheritance

Conversation

@lorenzocorallo

Copy link
Copy Markdown
Member

The rule

The built-in roles are meant to be out of admins' hands. Socio, Direttivo and Student come from the identity provider itself. Presidente and Segretario are given only by a Master Admin. Holding idp:roles:assign is not enough.

How it could be got around

A role counts as holding every role it inherits. Those inherited roles show up in the groups and polinetwork_roles claims and in the backend access snapshot, and the backend checks them.

So someone who is not Master Admin, with idp:roles:write and idp:roles:assign, and who holds the permissions Presidente grants, could:

  1. create a role helper that inherits from presidente (or socio, direttivo, segretario, student), with no permissions of its own;
  2. give helper to anyone.

That person then showed up everywhere as holding presidente and direttivo. Adding the parent to an existing role worked too.

What is refused now

Unless you are Master Admin:

  • You can't change which built-in roles any role inherits. This covers new roles, edits, deletes, and the indirect case (adding a built-in parent to role A also changes what A's child roles get). The check is in mayDelegateMutation.
  • You can't give or take back a role that inherits a built-in role, from the dashboard or the MCP server. The message names the built-in role, for example: "Only a Master Admin can assign helper, because it also gives Direttivo and Presidente."
  • The People path (backend changes on behalf of a dashboard user) refuses the same roles. You can still give up your own role.

Master Admin can still do all of this. Nobody can inherit from Master Admin, same as before. Built-in roles' own parents (Presidente and Segretario inherit Direttivo) don't get in the way of normal edits.

The shared logic is one small function, inheritedBuiltInRoles in src/auth/rbac.ts. The screens stop offering these parents and assignments to non-Masters. No new text was added to any screen. One small screen change: on a person's page, the Remove button is hidden for these roles, Presidente and Segretario included. Before, it was disabled with a tooltip that wasn't true.

How inherited roles are reported (claims, snapshot, People list) is unchanged.

Does this affect anything that exists?

No. No role in production inherits from a built-in role today.

How it was tested

  • Unit tests in src/auth/rbac.test.ts: the reproduction (create helper with parent presidente, then assign it) is refused at save and at assign. Also: every built-in parent, an existing role gaining one, the indirect case, removing or deleting one, Master Admin still allowed, and normal edits and assignments still allowed. The refusal tests fail on the old code.
  • src/auth/people-binding.test.ts: the People path.
  • src/components/rbac/delegation.test.ts: the browser helpers.
  • New PostgreSQL case in src/auth/rbac-security.integration.test.mjs. I ran it against a throwaway Postgres 17 container with the migrations applied: 31/31 passed. people-roles.integration.test.ts also passed (7/7) on the same database.
  • vp check passes. vp test passes: 369 passed, 126 skipped (the opt-in DB and HTTP suites).
  • I did not click through the UI in a browser.

Docs: the README "Roles and permissions" and People sections, a new §6 in docs/rbac-security-review.md, and one MCP tool description (set_role_people_binding) that was no longer true.

The commit is not signed: 1Password signing failed in this session, and you asked me to commit without signing.

…itance

A role reports every role it inherits, so a delegated role administrator
could create a role inheriting Presidente (or Socio, Direttivo,
Segretario, Student) and assign it to anyone. Unless Master Admin, a
change may no longer alter which built-in roles any role inherits, and
nobody else may give or take back a role that inherits one, from the
dashboard, the MCP server or People. The editor stops offering those
parents and assignments.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9fe232e and e4bc498.

Files selected for processing: 14

  • README.md
  • docs/rbac-security-review.md
  • src/auth/mcp-server.ts
  • src/auth/people-binding.test.ts
  • src/auth/people-binding.ts
  • src/auth/rbac-delegation.ts
  • src/auth/rbac-security.integration.test.mjs
  • src/auth/rbac-store.ts
  • src/auth/rbac.test.ts
  • src/auth/rbac.ts
  • src/components/rbac/delegation.test.ts
  • src/components/rbac/delegation.ts
  • src/components/rbac/role-form.tsx
  • src/components/users/user-roles.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant