GHSA-7G7P-FXX8-4WM8
[Security] Privilege escalation in invite_new_user_to_org: org_member can invite org_admin by bypassing rank check
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-7G7P-FXX8-4WM8 divulgada · CVSS 8.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
An authenticated user with `org_member` role (which holds `org.invite_user` permission)
can invite an external collaborator as `org_admin` — or any role above their own rank —
via `POST /private/invite_new_user_to_org`.
The endpoint only guards `org_super_admin` behind `org.update_user_roles`. All other
elevated roles (`org_admin`, `org_billing_admin`) are reachable with only `org.invite_user`.
Affected file
`supabase/functions/_backend/private/invite_new_user_to_org.ts` — `validateInvite()`
Root cause
// Current code — missing rank check
const isSuperAdminInvite = body.invite_type === 'org_super_admin'
const requiredPermission = isSuperAdminInvite
? 'org.update_user_roles'
: 'org.invite_user' // ← org_admin passes through hereThere is no comparison between the `priority_rank` of the requested role and the
caller's maximum rank. The equivalent check does exist in:
- `invite_existing_user_to_org.ts` → `canCallerResendInviteRole()`
- `role_bindings.ts` → `createRoleBindingForPrincipal()` → `getCallerMaxPriorityRank()`
Why database triggers do not catch this
`accept_invitation.ts` calls `ensureOrgMembership`, which inserts into `role_bindings`
using `supabaseAdmin` (service-role key). Both triggers
`prevent_role_binding_priority_escalation` and `check_org_user_privileges` check
`is_internal_request_role()` as their first line and return `NEW` immediately for
service-role requests — bypassing all rank enforcement at the DB level.
Steps to reproduce
- User A has role `org_member` (with `org.invite_user`) in org X.
- A calls:
POST /private/invite_new_user_to_org
{
"email": "attacker@example.com",
"org_id": "<X>",
"invite_type": "org_admin",
"first_name": "Test",
"last_name": "User"
}- Server creates a `tmp_users` row with `rbac_role_name = 'org_admin'`.
- `attacker@example.com` receives the magic-link email and calls
- `ensureOrgMembership` inserts an `org_admin` `role_binding` via service role.
- Attacker now has `org_admin` in org X. ✓
Impact
Any `org_member` with `org.invite_user` can escalate a confederate to `org_admin`,
gaining full administrative control over apps, channels, members, and billing of
any organization they belong to.
Suggested fix
After resolving `rbacRoleName` in `validateInvite`, add a rank comparison identical
to `canCallerResendInviteRole` already present in `invite_existing_user_to_org.ts`:
// Anti-escalation: caller's rank must be >= rank of the invited role
const canAssignTargetRole = await canCallerAssignRole(c, authContext, body.org_id, rbacRoleName)
if (!canAssignTargetRole) {
return quickError(403, 'not_authorized',
'Cannot invite a user to a role with higher privileges than your own',
{ orgId: body.org_id }
)
}I am happy to submit a PR with the fix once you confirm the issue.
<!-- private-maintainer-note -->
Private maintainer note: fix PR opened at https://github.com/Cap-go/capgo.app/pull/3096 (compare inviter rank before elevated invites). Reporter: please verify after merge+release for bounty eligibility per https://capgo.app/bug-bounty/.
---
Fix PR (merged)
Intentional fix PR https://github.com/Cap-go/capgo.app/pull/3096 merged 2026-08-26 (14:05 EEST). Inviter rank is compared before org_super_admin invites.
Shipped in production capgo-12.261.0 (2026-08-26). Reporter: please verify. Bounty/credit is due only after that verification, per Capgo bounty policy.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmcapgo |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/Cap-go/capgo.app/security/advisories/GHSA-7g7p-fxx8-4wm8Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
