Summary
A broken authorization control in Capgo allows direct modification of app ownership metadata via PostgREST without passing through the intended transfer_app() workflow.
Under certain conditions, an attacker can create split-brain ownership where one organization retains access to version data while another controls the app record, leading to confusing and insecure access boundaries.
Affected context
This vulnerability affects Capgo deployments that expose PostgREST-backed endpoints for manipulating app ownership records.
It manifests when the public.apps.owner_org field can be updated directly, without coordinated updates to related tables such as app_versions.owner_org and without enforcing the transfer_app() workflow.
Environments where ownership metadata is spread across multiple tables and not atomically updated are especially susceptible to split-brain states.
Exploit preconditions
- Attack surface: API endpoints exposed via PostgREST that allow write access to public.apps.owner_org
- Required access: Ability to authenticate or otherwise obtain credentials or roles that can perform direct updates on app ownership fields
- Trigger point: Issuing an update to apps.owner_org while leaving app_versions.owner_org unchanged, effectively bypassing the transfer_app() workflow
- Why exploitation is possible: Authorization checks are insufficiently coupled to the higher-level ownership transfer process, allowing direct field changes that violate consistency constraints and access control assumptions
Why this happens
The core issue is a broken access control pattern where low-level database fields governing ownership can be modified independently of the sanctioned transfer_app() workflow.
Instead of enforcing that all ownership changes flow through a controlled, transactional process, the system allows direct writes to public.apps.owner_org via PostgREST.
This maps to CWE-284, as authorization policies fail to restrict sensitive operations that affect who controls app records and associated data, resulting in inconsistent ownership metadata and unintended access paths.
Potential impact
- Attacker-controlled organization may gain ownership of app records without correctly transferring underlying version data
- Previous organization keys may continue to access version data, leading to unauthorized retention of data access
- Confusing split-brain ownership states that complicate incident response and access auditing
- Potential misuse of app records and version data by different organizations with divergent intentions
- Increased risk of data leakage or policy violations due to inconsistent enforcement of ownership constraints
General mitigation guidance
Effective mitigation focuses on enforcing ownership changes through a single, constrained workflow and eliminating direct updates to sensitive ownership fields.
Common defensive patterns include:
- Centralizing ownership transfer logic in an application-level function or service that performs atomic, cross-table updates
- Restricting PostgREST or similar data access layers from directly updating ownership-related columns, using database policies or views
- Implementing strong row-level security and role-based access control for ownership metadata so only dedicated workflows can modify it
- Applying integrity constraints or triggers to prevent inconsistent ownership states between apps and app_versions
- Designing ownership changes to be transactional and auditable, with clear logs of who initiated transfers and when
How teams detect issues like this
Organizations can identify this class of issue through:
- Code and schema reviews focused on ownership-related tables, looking for columns that can be modified outside sanctioned workflows
- Analysis of PostgREST configuration, policies, and database row-level security to ensure sensitive fields are not directly writable
- Database audit logging that flags changes to apps.owner_org and app_versions.owner_org, especially when they diverge
- Static analysis or policy-as-code checks that enforce patterns such as "no direct writes to ownership fields" and "all ownership changes must use transfer workflows"
- Periodic integrity checks to detect split-brain ownership states where related tables reference different owning organizations

