Summary
Capgo before version 12.128.2 allows upload-scoped API keys to modify the mutable app_versions.r2_path field via PostgREST, effectively retargeting app versions to arbitrary R2 bundle objects.
By abusing this missing authorization check, an attacker can point versions at victim bundles and trigger cleanup logic that deletes those objects, leading to denial of service and disruption of bundle availability.
Affected context
This vulnerability occurs in Capgo deployments where PostgREST exposes the app_versions resource to upload-scoped API keys and treats r2_path as a mutable field.
It is relevant when cleanup or lifecycle functions (such as on_version_update) operate on the R2 objects referenced by r2_path without strictly validating ownership, scope, or authorization.
Environments that rely on R2 bundle paths as the authoritative reference for application versions are particularly affected, since misdirected paths can cause destructive actions against unrelated bundles.
Exploit preconditions
- Attack surface: PostgREST API endpoints handling
app_versionsupdates and lifecycle events. - Required access: Possession of an upload-scoped API key or equivalent credentials with permission to patch
app_versions.r2_path. - Trigger point: Updating
r2_pathto point at a victim's R2 bundle and then invoking actions that causeon_version_updateor similar cleanup logic to run. - Why exploitation is possible: The API does not enforce sufficient authorization or ownership checks on which R2 objects an upload-scoped key may reference, allowing cross-tenant or cross-owner bundle targeting and subsequent deletion.
Why this happens
The underlying issue is a missing authorization control on a sensitive reference field (app_versions.r2_path) that governs access to external R2 bundle objects.
Instead of treating r2_path as a protected, ownership-validated field, the system allows upload-scoped keys to arbitrarily change it, and downstream cleanup logic trusts the new value as legitimate.
This maps to CWE-862: Missing Authorization, where the application fails to verify whether the caller is allowed to perform a specific action or affect a specific resource, enabling destructive operations on bundles belonging to other parties.
Potential impact
- Attackers may delete victim R2 bundle objects by misdirecting cleanup routines.
- Application versions can be pointed to incorrect or malicious bundles, causing functional disruption.
- Service operators may experience denial of service due to missing or unavailable bundles.
- Integrity of deployment artifacts can be compromised by unauthorized retargeting of bundle paths.
General mitigation guidance
Effective mitigation focuses on enforcing strict authorization and ownership validation around resource-linking fields and lifecycle operations.
Common patterns include:
- Treating fields that reference external storage objects (such as
r2_path) as privileged metadata, only modifiable by trusted, higher-scope roles. - Implementing server-side authorization rules that ensure any referenced bundle belongs to the same tenant, application, or owner as the version being updated.
- Separating upload capabilities from resource lifecycle management so that upload-scoped keys cannot trigger destructive cleanup actions.
- Designing cleanup and
on_version_updatelogic to verify resource ownership and scope before performing deletions or destructive state transitions.
How teams detect issues like this
Organizations can detect similar authorization gaps by:
- Reviewing API schemas and PostgREST configurations for fields that reference external resources and verifying that they are not writable by low-privilege roles.
- Applying static and configuration analysis to identify missing row-level security, ownership checks, or policy constraints on mutation endpoints.
- Instrumenting audit logging for changes to sensitive reference fields (e.g.,
r2_path) and monitoring for cross-tenant or unusual retargeting behavior. - Using automated policy enforcement tools or database-level RLS (Row-Level Security) to ensure that lifecycle routines operate only on resources associated with the authenticated principal.

