Skip to main content
Menu
Advisories

Unauthenticated SSO check-domain Endpoint Exposes Internal org_id and provider_id

GHSA-C5JF-5WXG-MGRQPublished Updated GitHub

Description

The /private/sso/check-domain endpoint returns internal org_id and provider_id values in its JSON response to unauthenticated callers. These fields are not consumed by any frontend client code and serve no purpose in the response. An attacker can enumerate email domains to build a mapping of domains to internal organization UUIDs and SSO provider identifiers, enabling targeted reconnaissance against Capgo tenants.

Details

The check-domain endpoint is designed to be called pre-authentication so the login page can detect whether SSO enforcement applies. Unlike the adjacent check-enforcement endpoint, it deliberately omits auth middleware — but it also returns more data than the client needs.

No auth middleware — check-domain.ts:50 mounts a bare handler:

// supabase/functions/_backend/private/sso/check-domain.ts:50
app.post('/', async (c) => {

Compare with check-enforcement.ts:10 which requires a valid JWT:

// supabase/functions/_backend/private/sso/check-enforcement.ts:10
app.post('/', middlewareAuth, async (c) => {

Unnecessary fields in response — check-domain.ts:111-116 returns provider_id and org_id alongside the two fields the client actually reads (has_sso, enforce_sso):

// supabase/functions/_backend/private/sso/check-domain.ts:111-116
return c.json({
  has_sso: true,
  enforce_sso: enforcementRow?.enforce_sso === true,
  provider_id: legacyRow?.provider_id,                    // unused by client
  org_id: enforcementRow?.org_id ?? legacyRow?.org_id,    // unused by client
})

The frontend login flow (login.vue, useSSORouting.ts) only reads has_sso and enforce_sso — neither org_id nor provider_id is consumed.

Uses anonymous Supabase client — check-domain.ts:71 uses emptySupabase(c) (anon key, no user context), confirming the endpoint is intentionally unauthenticated.

Rate limit is trivially bypassable — The IP-based rate limit of 10 requests/minute (check-domain.ts:12) can be bypassed by rotating source IPs (proxies, cloud functions), enabling bulk domain enumeration.

PoC

Step 1 — Query a domain with SSO configured:

curl -s -X POST https://<capgo-instance>/private/sso/check-domain \
  -H "Content-Type: application/json" \
  -d '{"email": "user@target-company.com"}'

Expected response (current — leaks internal IDs):

{
  "has_sso": true,
  "enforce_sso": true,
  "provider_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "org_id": "f9e8d7c6-b5a4-3210-fedc-ba0987654321"
}

Step 2 — Enumerate multiple domains to map organizations:

for domain in target1.com target2.com target3.com; do
  echo -n "$domain: "
  curl -s -X POST https://<capgo-instance>/private/sso/check-domain \
    -H "Content-Type: application/json" \
    -d "{\"email\": \"test@${domain}\"}" | jq '{org_id, provider_id}'
done

This produces a domain → org_id mapping with no authentication required.

Impact

  • Organization enumeration: An unauthenticated attacker can determine which domains have Capgo organizations and map them to internal org UUIDs.
  • SSO provider fingerprinting: The provider_id reveals which SSO identity provider is configured, aiding targeted phishing or social engineering.
  • Reconnaissance for downstream attacks: While org_id is an opaque UUID and other endpoints enforce their own auth, the mapping reduces the attack surface an adversary must explore when targeting specific tenants.
  • Principle of minimal disclosure violated: The endpoint returns data that no client consumes, unnecessarily expanding the information surface.

Note: No direct privilege escalation chain exists from these fields alone — endpoints that accept org_id enforce independent authorization checks. The practical impact is limited to reconnaissance.

Recommended Fix

Remove the two unused fields from the response in supabase/functions/_backend/private/sso/check-domain.ts:

     return c.json({
       has_sso: true,
       enforce_sso: enforcementRow?.enforce_sso === true,
-      provider_id: legacyRow?.provider_id,
-      org_id: enforcementRow?.org_id ?? legacyRow?.org_id,
     })

The cloudlog call at lines 102-109 can retain the fields for internal debugging — only the client-facing response needs to be trimmed. No frontend changes are required since neither field is read by the client.

Affected versions

References

GitHub · Cap-go/capgo.app