llamaCVEVulnerability Intelligence
/
Advisory · GitHub

GHSA-MQR8-G67P-JM26

Build upload proxy ignores upload expiry and lifecycle state before forwarding writes to the builder

Sin parche publicado
Descargar PNG JSON
CVSS
—
medium
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición70 dDesde la divulgación, 10 sept 2026, 10:10 a. m.
Detección69 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
10 sept 26
18 nov 26
19 nov 26
10 sept 26
28 sept 26
15 oct 26
2 nov 26
19 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-MQR8-G67P-JM26 divulgada
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

The Capgo native build upload proxy persists an upload expiry timestamp for each build request, but the `/build/upload/:jobId` TUS proxy does not enforce that expiry before forwarding upload requests to the internal builder.

When a build request is created, `upload_expires_at` is set to one hour in the future and returned to the client. However, the upload proxy only loads `app_id`, `owner_org`, `builder_job_id`, and `upload_path` from `build_requests`.

It does not select or validate `upload_expires_at`, `status`, or any lifecycle state before forwarding `POST`, `PATCH`, or `HEAD` requests to the builder.

As a result, Capgo's API layer allows a caller with `app.build_native` permission to keep using `/build/upload/:jobId` even after the locally stored upload expiry or after the build lifecycle has moved beyond the upload phase, unless the separate builder service independently rejects the request.

Details

Affected source files:

  1. `supabase/functions/_backend/public/build/request.ts:258-295`

The build request creates and stores a one-hour upload expiry:

const upload_expires_at = new Date(Date.now() + 60 * 60 * 1000)

const upload_url = `${getEnv(c, 'PUBLIC_URL') || 'https://api.capgo.app'}/build/upload/${builderJob.jobId}`

const { data: buildRequestRow, error: insertError } = await supabaseAdminClient
.from('build_requests')
.insert({
app_id,
owner_org: org_id,
requested_by: apikey.user_id,
platform,
build_mode,
build_config,
status: 'pending',
builder_job_id: builderJob.jobId,
upload_session_key,
upload_path,
upload_url,
upload_expires_at: upload_expires_at.toISOString(),
})

  1. `supabase/functions/_backend/public/build/request.ts:313-320`

The expiry is returned to the client as part of the build request response:

return c.json({
build_request_id: buildRequestRow.id,
job_id: builderJob.jobId,
upload_session_key,
upload_path,
upload_url, // Capgo proxy URL
upload_expires_at: upload_expires_at.toISOString(),
status: buildRequestRow.status,

  1. `supabase/functions/_backend/public/build/upload.ts:45-49`

The upload proxy does not select `upload_expires_at` or `status`:

const { data: buildRequest, error: buildRequestError } = await supabase
.from('build_requests')
.select('app_id, owner_org, builder_job_id, upload_path')
.eq('builder_job_id', jobId)
.single()

  1. `supabase/functions/_backend/public/build/upload.ts:61-70`

The proxy only checks whether the caller has `app.build_native` permission for the app:

if (!(await checkPermission(c, 'app.build_native', { appId: buildRequest.app_id }))) {
cloudlogErr({
requestId: c.get('requestId'),
message: 'Unauthorized TUS upload',
job_id: jobId,
app_id: buildRequest.app_id,
user_id: apikey.user_id,
})
throw simpleError('unauthorized', 'You do not have permission to upload for this build')
}

  1. `supabase/functions/_backend/public/build/upload.ts:246-258`

After that, the request is forwarded directly to the builder:

const forwardInit: RequestInit = {
method: forwardMethod,
headers,
}

if (forwardMethod !== 'HEAD' && forwardMethod !== 'GET') {
forwardInit.body = c.req.raw.body
// @ts-expect-error - duplex is valid for streaming
forwardInit.duplex = 'half'
}

const builderResponse = await fetch(builderTusUrl, forwardInit)

There is no Capgo-side check for:

buildRequest.upload_expires_at > now()
buildRequest.status === 'pending' or another upload-allowed state
build not already started
build not already completed
build not already cancelled
upload not already finalized

Vulnerable invariant

The build upload proxy should only forward TUS writes while the build request is in an upload-allowed state.

Expected invariant:

A caller may upload build ZIP bytes only before upload_expires_at and only while the build request is in a state that permits upload.

Actual behavior:

/build/upload/:jobId only checks app.build_native permission and path ownership, then forwards the request to the builder regardless of upload_expires_at or build lifecycle state.

PoC

I confirmed the issue with a local unit-level PoC against `tusProxy()`.

The test mocked a `build_requests` row with an expired upload timestamp and a completed lifecycle state:

status: completed
upload_expires_at: 2000-01-01T00:00:00.000Z

Then it called `tusProxy()` with a `PATCH` request to:

/build/upload/job-expired-completed-test/artifact.zip

Expected secure result:

tusProxy() should reject locally before forwarding to the builder.

Actual result:

tusProxy() forwarded the PATCH request to the builder.

Test output:

stdout | tests/build-upload-expiry-state.temp.test.ts > build upload proxy expiry/state boundary > currently forwards PATCH even when the build request is expired and completed
requestId test-request-id message TUS proxy request job_id job-expired-completed-test method PATCH forward_method PATCH

stdout | tests/build-upload-expiry-state.temp.test.ts > build upload proxy expiry/state boundary > currently forwards PATCH even when the build request is expired and completed
requestId test-request-id message Upload path validated job_id job-expired-completed-test upload_path orgs/org-expired-completed/apps/com.test.expired.completed/native-builds/file.zip
requestId test-request-id message Proxying TUS request to builder job_id job-expired-completed-test method PATCH forward_method PATCH original_path /build/upload/job-expired-completed-test/artifact.zip upload_prefix /build/upload/job-expired-completed-test tus_path /artifact.zip builder_url https://builder.capgo.app/upload/artifact.zip has_api_key true
requestId test-request-id message Request headers prepared for builder job_id job-expired-completed-test has_x_api_key true

stdout | tests/build-upload-expiry-state.temp.test.ts > build upload proxy expiry/state boundary > currently forwards PATCH even when the build request is expired and completed
requestId test-request-id message Builder TUS response job_id job-expired-completed-test status 204

✓ tests/build-upload-expiry-state.temp.test.ts (1 test) 32ms
✓ build upload proxy expiry/state boundary (1)
✓ currently forwards PATCH even when the build request is expired and completed 31ms

This proves that the public upload proxy forwards lifecycle-invalid and expired upload requests to the builder as implemented.

Impact

A caller with native-build permission can potentially reuse an old or lifecycle-invalid `/build/upload/:jobId` TUS endpoint after the upload window has expired, or after the build has started, completed, or been cancelled.

Depending on builder behavior, this can lead to:

  • late upload after Capgo's stated expiry
  • build artifact replacement or corruption
  • upload/session reuse after lifecycle transition
  • inconsistent state between Capgo's `build_requests` table and the builder
  • possible denial of service for a build job by modifying or corrupting the uploaded ZIP after the expected upload phase

This is especially sensitive because the Capgo API stores `upload_expires_at`, returns it to the client, and appears to treat it as a meaningful upload validity boundary. However, the actual upload proxy does not enforce it.

Why this matters even if the builder has its own checks

The Capgo API is the public authorization boundary for `/build/upload/:jobId`.

Even if the builder independently enforces expiry or write-once behavior, the Capgo API still forwards expired or lifecycle-invalid requests to the builder. That creates a split-brain security model where the database has an expiry and status, but the public proxy does not use them for authorization.

The safer invariant is to reject invalid upload attempts at the Capgo API layer before forwarding anything to the builder.

Strongest false-positive reason

The internal builder may independently enforce TUS session expiry, upload finalization, write-once semantics, or job lifecycle state. If so, production exploitation may be blocked by the builder even though the Capgo API proxy forwards the request.

However, the Capgo API already stores `upload_expires_at` and `status` locally, but does not use them in the upload proxy. The public proxy should not rely solely on a downstream internal service to enforce the expiry and lifecycle boundary.

Suggested fix

Select and enforce `upload_expires_at` and `status` in the upload proxy before forwarding.

Example:

const { data: buildRequest, error: buildRequestError } = await supabase
.from('build_requests')
.select('app_id, owner_org, builder_job_id, upload_path, upload_expires_at, status')
.eq('builder_job_id', jobId)
.single()

if (new Date(buildRequest.upload_expires_at).getTime() <= Date.now()) {
throw simpleError('upload_expired', 'Build upload URL has expired')
}

const uploadAllowedStatuses = new Set(['pending'])

if (!uploadAllowedStatuses.has(buildRequest.status)) {
throw simpleError('invalid_state', 'Build upload is not allowed in the current build state')
}

The exact allowed status set depends on Capgo's intended build lifecycle, but the check should happen before constructing `forwardInit` and before calling `fetch(builderTusUrl, forwardInit)`.

---

Fix

This was fixed by intentional security PR https://github.com/Cap-go/capgo.app/pull/3091 (`fix(security): bind native-build TUS proxy to job upload lifecycle`), merged 2026-09-01.

The upload proxy now selects `upload_expires_at` and `status`, rejects expired windows, and only forwards while the build request is `pending`.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Remediación

Estado del parche por paquete

La fuente no informa paquetes ni versiones corregidas.

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-mqr8-g67p-jm26

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