Summary
Capgo's organization management API contains a broken access control flaw where scoped API keys inherit the full permissions of their owning user, ignoring the key's organization restriction.
In scenarios where a user administers multiple organizations, a write-mode key scoped to one organization can still perform destructive operations against other organizations, leading to cross-tenant impact.
Affected context
This vulnerability appears in Capgo deployments that:
- Use the organization management API with scoped API keys (
limited_to_orgs) - Allow users to be admins or owners of multiple organizations
- Rely on route-level RBAC checks that resolve permissions from the key's owning user
The risk is most pronounced in multi-tenant environments where one user holds administrative roles across organizations and delegates access through write-mode API keys.
Exploit preconditions
- Attack surface: Capgo organization management HTTP API endpoints (e.g.,
DELETE /organization,DELETE /organization/members). - Required access: Possession of a valid write-mode API key that is nominally scoped to at least one organization via
limited_to_orgs. - Trigger point: Making destructive organization-management requests with the scoped API key against organizations where the owning user has admin rights, even if those orgs are not listed in the key's scope.
- Why exploitation is possible: The route-level authorization logic (
rbac_check_permission_direct) evaluates the privileges of the API key's owner-user and authorizes the request before enforcing (or instead of correctly enforcing) the API key'slimited_to_orgsrestriction, effectively bypassing the intended scope.
Why this happens
The underlying issue is a misapplied authorization model, aligning with CWE-285: Improper Authorization.
Instead of binding access decisions strictly to the API key's declared scope, the implementation derives effective permissions from the owning user's RBAC profile at the route level.
This mixes two trust contexts—user-level privileges and key-level restrictions—without a clear precedence rule that favors the more restrictive scope.
As a result, scoped API keys become over-privileged whenever their owner has broader cross-organization permissions, enabling actions outside the intended tenant boundary.
Potential impact
- Destructive actions (e.g., delete organization) can be performed against other organizations where the user is an admin.
- Unauthorized removal or modification of members in unrelated organizations.
- Cross-tenant data and configuration loss or corruption across organizations sharing the same admin.
- Escalation of delegated access, where a narrowly scoped key effectively grants broad administrative capabilities.
- Erosion of tenant isolation guarantees, reducing trust in multi-organization and multi-tenant setups.
General mitigation guidance
Effective mitigation focuses on enforcing scope-first authorization and strengthening tenant isolation boundaries.
Common defensive patterns include:
- Evaluating access decisions against the API key's attributes (such as
limited_to_orgsand mode) as the primary authority, treating user-level privileges only as an upper bound, never as a way to broaden key scope. - Designing authorization middleware that composes constraints in a "least-privilege" way, always intersecting user permissions with key restrictions instead of taking their union.
- Normalizing organization tenancy checks so that every sensitive route requires an explicit organization context that must be validated against the key's allowed organizations.
- Avoiding implicit inheritance of privileges between principals (e.g., from user to API key) without a clear, testable policy.
- Applying defense in depth with additional checks server-side, such as explicit tenant IDs and ownership verification on destructive operations.
How teams detect issues like this
Detection typically combines code-level review and behavioral monitoring:
- Static analysis and code review: Look for authorization paths where requests authenticated via API keys still consult user RBAC objects directly (e.g., calls to
rbac_check_permission_directthat reference the owning user rather than the key's scope). - Policy enforcement checks: Encode authorization rules declaratively (e.g., policy-as-code) and verify that organization-scoped keys can only act within their specified tenants.
- Unit and integration tests: Add negative tests ensuring that a scoped API key cannot perform actions on organizations outside its
limited_to_orgslist, even if the owner has broad privileges. - Runtime monitoring: Instrument logs with identifiers for both the API key and target organization; alert on patterns where a key acts on organizations not listed in its configured scope.

