Skip to content

security(scim): scope user deprovisioning to the calling org - #854

Merged
lakhansamani merged 2 commits into
mainfrom
security/scim-org-scoped-deprovision
Nov 8, 2026
Merged

lakhansamani merged 2 commits into
mainfrom
security/scim-org-scoped-deprovision

Conversation

@lakhansamani

Copy link
Copy Markdown
Contributor
  • Fixes GHSA-93q4-j2hq-5qgg. A SCIM token belongs to one organization, but deprovisioning wrote the GLOBAL user row (is_active=false and the revocation marker) and deleted every session keyed by user id. Org A could disable a shared account, and end its live sessions, for org B — including one of B's own org admins. Two breaking changes: PATCH {"active": true} restores the membership only and does not lift a global revocation while the user stays active in another organization; deprovision deletes the user's FGA grants inside that organization and reprovision does not restore them, so the IdP must re-sync group membership and an admin must re-grant each manual grant.
  • internal/storage/schemas/org_membership.go: add DeprovisionedAt *int64 and the Active() helper. It is a nullable timestamp and not an IsActive bool on purpose — no backend backfills a new column, so a SQL NULL, an unset Cassandra column and an absent document key all decode to false, and a bool locks every existing member out on upgrade. Absent must mean active.
  • internal/service/scim/scim.go: SetActive, ReplaceUser and PatchUser deprovision the MEMBERSHIP, and take the global account down only when no other organization still has the user active. Read paths report active per organization. The count of other active memberships runs AFTER the membership write, because the read-then-write order lets two organizations deprovision at the same time and leave a live account with no active membership.
  • internal/service/scim/groups.go, internal/http_handlers/oauth_sso.go: deprovision DELETES every FGA tuple that names the user inside that organization, and SSO/JIT login gates on the membership. Without both, check_permissions keeps answering allowed and the member logs back in through the organization's own SSO endpoint. An access token already issued for the organization still works until it expires, because schemas.Session and SessionToken carry no org id. Risk to check: the purge scopes by the object's <type>:<orgID>/ prefix, so a model that namespaces objects differently is missed.
  • internal/service/admin_provider.go, internal/service/admin_organizations.go, internal/http_handlers/saml_idp.go: deny a deprovisioned membership, and count only ACTIVE admins in the last-admin guard. Org-admin authority, SAML assertion issuance and the guard disagreed about what a member is, which let the last active admin remove themselves.

A SCIM token is issued per organization, but deprovisioning wrote the global
user row and deleted every session, so one org could disable a shared account
for all the others. Membership existence also granted org-admin authority.
Withholding the global revocation marker left the paths that relied on it
ungated, so a deprovisioned member kept this org's FGA grants and could log
back in through its own SSO endpoint.
@lakhansamani
lakhansamani merged commit d6d361e into main Nov 8, 2026
3 of 4 checks passed
@lakhansamani
lakhansamani deleted the security/scim-org-scoped-deprovision branch November 8, 2026 11:00
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