llamaCVEVulnerability Intelligence
/
Advisory · GitHub · npm · capgo

GHSA-7G7P-FXX8-4WM8

[Security] Privilege escalation in invite_new_user_to_org: org_member can invite org_admin by bypassing rank check

Sin parche publicado
Descargar PNG JSON
CVSS 3.1
8.1
Alta
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición84 dDesde la divulgación, 27 ago 2026, 3:40 a. m.
Detección83 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
27 ago 26
18 nov 26
20 nov 26
27 ago 26
17 sept 26
8 oct 26
29 oct 26
20 nov 26
FechaFaseEventoDetalle
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
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

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 here

There 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

  1. User A has role `org_member` (with `org.invite_user`) in org X.
  2. 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"
}
  1. Server creates a `tmp_users` row with `rbac_role_name = 'org_admin'`.
  2. `attacker@example.com` receives the magic-link email and calls
  3. `ensureOrgMembership` inserts an `org_admin` `role_binding` via service role.
  4. 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.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:L
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:H
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:N
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida
capgo≤ 12.207.1
12.207.1
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
npmcapgo
Sin parche — — —
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/Cap-go/capgo.app/security/advisories/GHSA-7g7p-fxx8-4wm8

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.