GHSA-F83X-P28R-PF74
SQL Injection in Cloudflare Analytics Engine Queries (cloudflare.ts)
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-F83X-P28R-PF74 divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Multiple SQL injection vulnerabilities exist in `supabase/functions/_backend/utils/cloudflare.ts`. User-controlled values from API request bodies are interpolated directly into SQL query strings sent to the Cloudflare Analytics Engine API without sanitization or parameterization.
Severity: HIGH
An authenticated user with read-level API key permissions can inject arbitrary SQL into Cloudflare Analytics Engine queries, potentially accessing data belonging to other users/apps.
Most Critical Injection Point
File: `supabase/functions/_backend/utils/cloudflare.ts`, lines 668-669
const devicesList = params.deviceIds.join(',')
deviceFilter = `AND device_id IN (${devicesList})`deviceIds are joined WITHOUT any quoting or escaping, making injection trivial.
Attack Vector
Entry Points:
- POST /private/devices -> devices.ts -> readDevices -> readDevicesCF
- POST /private/stats -> stats.ts -> readStats -> readStatsCF
Both require middlewareV2 auth (read-level API key). The `devicesId` field is validated as `z.array(z.string())` which only checks type, not content. SQL payloads pass validation.
All Injection Points
| Function | Line | Parameter | Quotes? |
|----------|------|-----------|---------|
| readDevicesCF | 562 | deviceIds[0] | Yes but unescaped |
| readDevicesCF | 565 | deviceIds[] | Yes but unescaped |
| readDevicesCF | 574,578 | search | Yes but unescaped |
| readDevicesCF | 583 | version_name | Yes but unescaped |
| readDevicesCF | 592 | cursor | Yes but unescaped |
| readStatsCF | 665 | deviceIds[0] | Yes but unescaped |
| readStatsCF | 668-669 | deviceIds[] | NO QUOTES |
| readStatsCF | 677,680 | actions | Yes but unescaped |
| readStatsCF | 689-691 | search | Yes but unescaped |
| readBandwidthUsageCF | 401 | app_id | Yes but unescaped |
| readDeviceUsageCF | 340 | app_id | Yes but unescaped |
Impact
- Data exfiltration - read analytics data from other users' apps
- Cross-tenant data access - break app_id isolation in multi-tenant queries
- Information disclosure - enumerate device IDs, versions, usage patterns of other apps
Proof of Concept
The most critical injection (line 668-669) - deviceIds joined without quotes:
POST /private/stats
Authorization: Bearer <valid-read-api-key>
{
"appId": "com.example.app",
"devicesId": ["1) OR 1=1 UNION SELECT * FROM stats WHERE app_id != 'com.example.app' --"]
}This modifies the query to:
... AND device_id IN (1) OR 1=1 UNION SELECT * FROM stats WHERE app_id != 'com.example.app' --)Suggested Fix
Create a sanitizeSqlString() utility and apply to ALL user-controlled values:
function escapeSql(value: string): string {
return value.replace(/'/g, "''")
}
function validateDeviceId(id: string): string {
if (!/^[a-zA-Z0-9_\-:.]+$/.test(id)) {
throw new Error(`Invalid device ID: ${id}`)
}
return id
}Apply strict input validation regex for deviceIds, search, version_name, cursor, and actions across all query-building functions in cloudflare.ts.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
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-f83x-p28r-pf74Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
