GHSA-CW88-CH2J-8VQJ
Preview subdomain app lookup uses ILIKE with user-controlled appId; _ wildcard collisions break preview (app_not_found) and can cause app-id confusion
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-CW88-CH2J-8VQJ divulgada · CVSS 5.3 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
### Summary
The bundle preview feature (*.preview.capgo.app) resolves app_id from the preview subdomain and looks it up using a Postgres ILIKE query. Because Capgo allows underscores (_) in apps.app_id, and _ is a single-character wildcard in SQL LIKE/ILIKE, certain app_id values can unintentionally match multiple rows. The preview handler uses .single(), so multi-match conditions lead to a hard failure and the preview endpoint returns app_not_found even when the app exists and preview is enabled.
### Details
Relevant code paths:
- App ID validation allows _:
supabase/functions/_backend/utils/utils.ts
reverseDomainRegex = /^[a-z0-9]+(\.[\w-]+)+$/i
(\w includes _), therefore app IDs like ee.forgr.capacitor_go.new2 are permitted.
- Preview app lookup uses ILIKE + .single():
supabase/functions/_backend/files/preview.ts
const { data: appData, error: appError } = await supabase
.from('apps')
.select('app_id, allow_preview')
.ilike('app_id', appId)
.single()In Postgres, _ is a wildcard for any single character in LIKE/ILIKE, so an app_id containing _ becomes a pattern, not a literal match. If there is another app with the same shape (e.g. capacitorXgo), the query matches multiple rows and .single() fails, leading the handler to return app_not_found.
Recommended fix:
- Use exact match rather than pattern match: .eq('app_id', appId) (and normalize case if needed by storing a normalized app_id_lower and comparing .eq('app_id_lower', appId.toLowerCase())).
- Alternatively, escape LIKE wildcards (_ and %) before using LIKE/ILIKE (less preferred).
- Optionally, disallow _ in app_id if not required.
### PoC
The following steps reproduce the issue using only normal product functionality.
- Identify an existing app with _ in app_id (example used in this PoC):
- ee.forgr.capacitor_go.new2
- Create a “partner” app in the same org that differs by exactly one character at the underscore position (so _ wildcard matches it). Example:
- ee.forgr.capacitorXgo.new2
Request used (example):
API="https://api.capgo.app"
KEY="redacted"
A_UNDERSCORE="ee.forgr.capacitor_go.new2"
A_PARTNER="ee.forgr.capacitorXgo.new2"
ORG_ID="$(curl -sk "$API/app?limit=200" -H "capgkey: $KEY" \
| jq -r --arg A "$A_UNDERSCORE" '.[] | select(.app_id==$A) | .owner_org' | head -n 1)"
curl -sk -i -X POST "$API/app" \
-H "capgkey: $KEY" -H "content-type: application/json" \
--data "{\"app_id\":\"$A_PARTNER\",\"name\":\"preview-ilike-partner\",\"owner_org\":\"$ORG_ID\"}"- Enable preview for the underscore app in the dashboard:
- console.capgo.app → App settings → check “Allow bundle preview”
4. Call the preview domain for both apps (any version id works for reaching the auth/app lookup layer; VID=1 used here):
A) Underscore app returns app_not_found (incorrect):
ENC="ee__forgr__capacitor_go__new2"
VID="1"
curl -sk -i "https://${ENC}-${VID}.preview.capgo.app/" | sed -n '1,200p'Observed response:
- HTTP 400
- {"error":"app_not_found","message":"App not found","moreInfo":{"appId":"ee.forgr.capacitor_go.new2"}}
B) Partner app reaches normal gating (preview_disabled when not enabled):
ENC="ee__forgr__capacitorXgo__new2"
VID="1"
curl -sk -i "https://${ENC}-${VID}.preview.capgo.app/" | sed -n '1,200p'Observed response:
- HTTP 400
- {"error":"preview_disabled","message":"Preview is disabled for this app","moreInfo":{}}
This demonstrates the underscore app_id is failing due to the lookup behavior, not due to bundle/version presence.
Impact
- Preview DoS / broken functionality for affected apps: apps with underscores in app_id can have preview become unreachable if a wildcard-colliding app_id exists.
- Potential app-id confusion risk if the implementation changes or if error-handling is altered (the root cause is pattern matching on identifiers).
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmcapgo |
Corregida | 12.128.2 | — | — |
12.128.2Arsenal 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-cw88-ch2j-8vqjLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
