GHSA-26X3-6MR7-989P
Deleted bundle artifacts can be served from edge cache and restored into storage
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-26X3-6MR7-989P divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Deleted bundle artifacts can be served from edge cache and restored into storage
Summary
The public attachment read endpoint can keep a soft-deleted bundle available after the bundle has been deleted. The route checks that the parent app still exists, then serves a cached response before checking R2, and on cache hits it attempts to restore the cached bytes back into R2 when the object is missing.
Affected code paths:
- `supabase/functions/_backend/files/files.ts`
- `supabase/functions/_backend/public/bundle/delete.ts`
- `supabase/functions/_backend/triggers/on_version_update.ts`
- `public.update_app_versions_retention`
Impact
Bundle deletion and retention both mark `app_versions.deleted = true`; the update trigger then deletes the R2 object and clears stored size/manifest metadata. That creates a reasonable expectation that the old artifact is no longer retrievable through the public file endpoint.
If the artifact URL was cached before deletion, an unauthenticated request to the same `/files/read/attachments/...` URL can still receive the deleted bundle bytes. The same cache-hit branch also performs a best-effort restore by writing the cached bytes back into R2 when `head(fileId)` misses, undoing the physical deletion.
Practical impact:
- A deleted bundle can remain downloadable by anyone who has the old URL while the edge cache entry exists.
- The first post-deletion cache hit can re-create the deleted object in storage.
- Retention and explicit bundle delete can be bypassed for previously cached artifacts unless every relevant cache entry is purged.
This is a source-level, non-destructive report. I did not probe production data.
Evidence
Deletion marks versions as deleted:
.from('app_versions')
.update({
deleted: true,
})
.eq('app_id', body.app_id)
.eq('name', body.version)Retention does the same:
UPDATE public.app_versions
SET deleted = true
WHERE app_versions.deleted = falseThe update trigger treats that as a soft delete via `deleted_at` and physically deletes the bundle object:
if (record.deleted_at && record.deleted_at !== oldRecord.deleted_at)
return deleteIt(c, record)deleted = await s3.deleteObject(c, record.r2_path)The public file read route is unauthenticated:
app.get(`/read/${ATTACHMENT_PREFIX}/:id{.+}`, setKeyFromIdParam, getHandler)The read guard only validates path shape and that the parent app still exists:
const app = await getAppByAppIdPg(c, scopedPath.app_id, drizzleClient)
if (!app || app.owner_org !== scopedPath.owner_org) {
quickError(404, 'not_found', 'Not found')
}It does not verify that the requested `fileId` still belongs to a non-deleted `app_versions` row or manifest entry.
After that, `getHandler` serves the cache before checking R2:
let response = await cache.match(cacheKey)
if (response != null) {
response = ensureNoTransformResponse(response)
...
return response
}Inside the same cache-hit branch, it restores cached bytes into R2 if the object is missing:
const head = await new RetryBucket(bucket, DEFAULT_RETRY_PARAMS).head(fileId)
if (head != null)
return
const cached = response.clone()
const data = await cached.arrayBuffer()
...
await bucket.put(fileId, data, { httpMetadata })Relevant line references in the reviewed tree:
- `files.ts:341-357`: app-only read guard
- `files.ts:438-469`: cache hit served before R2 read
- `files.ts:451-458`: cache hit writes missing object back to R2
- `files.ts:1081`: unauthenticated public read route
- `delete.ts:27-36`: bundle delete sets `deleted = true`
- `on_version_update.ts:291-307`: deleted version removes the R2 object
- `on_version_update.ts:341-352`: update trigger calls deletion cleanup when `deleted_at` changes
- `20250530233128_base.sql:3257-3276`: retention marks versions deleted
Local proof
I included a small proof script:
output/income-actions/capgo-cache-resurrection-advisory-2026-05-10/deleted-bundle-cache-resurrection-proof.mjsIt performs two checks:
- Verifies the source patterns above exist in the local tree.
- Simulates a deleted `app_versions` row whose parent app still exists, a cache hit for the deleted `r2_path`, and an R2 `head()` miss. The Capgo-equivalent flow returns HTTP 200 and records a `bucket.put(fileId, cachedBytes)` restore.
Expected output:
{
"finding": "deleted bundle cache hit is served and written back to storage",
"deletedVersionState": {
"deleted": true,
"deleted_at": "2026-05-10T00:00:00.000Z"
},
"appScopedReadGuardDecision": "allows because the parent app still exists",
"publicReadResult": 200,
"restoredObjectKey": "orgs/11111111-1111-4111-8111-111111111111/apps/com.example.private/1.2.3.zip"
}Suggested fix
Before returning a cached response or restoring cached bytes, verify that the requested `fileId` is still an active artifact:
- For whole-bundle paths, require a matching `app_versions.r2_path = fileId` row with `deleted = false` and `deleted_at IS NULL`.
- For manifest paths, require a matching active manifest entry joined to a non-deleted `app_versions` row.
- If no active row exists, return 404 and delete or bypass the cache entry.
- Remove the automatic cache-to-R2 restore for paths that are not positively known to be active.
Defense in depth:
- Purge cache keys when a version is soft-deleted.
- Include deletion/version state in the cache key, or avoid public edge caching for bundle URLs whose backing row can be revoked.
<!-- private-maintainer-note -->
Private maintainer note: fix PR opened at https://github.com/Cap-go/capgo.app/pull/3100 (stop serving/restoring deleted bundle cache). Reporter: please verify after merge+release for bounty eligibility per https://capgo.app/bug-bounty/.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmcapgo-app |
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-26x3-6mr7-989pLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
