Summary
A privilege inversion flaw in Cap-go's build logs endpoint lets holders of read-only API keys cancel running native builds simply by disconnecting from the log stream.
Because the server uses a highly privileged key without re-checking permissions, attackers can repeatedly disrupt build pipelines and CI/CD workflows by abusing a log-viewing interface.
Affected context
The vulnerability appears in Cap-go deployments that expose the GET /build/logs/:jobId Server-Sent Events (SSE) endpoint to clients with read-only API keys.
In affected versions, this endpoint registers an abort listener that unconditionally triggers build cancellation using a privileged server-side BUILDER_API_KEY.
Environments that rely on the explicit POST /build/cancel/:jobId endpoint and its app.build_native permission check may unknowingly have a second, less visible path to cancel builds whenever a log stream is opened and dropped.
Exploit preconditions
- Attack surface: HTTPS API, specifically the
GET /build/logs/:jobIdSSE endpoint. - Required access: Possession of a valid read-only API key capable of accessing build logs, but not normally allowed to cancel builds.
- Trigger point: Initiating a log stream to a running native build job and then disconnecting the SSE connection (e.g., closing the client, dropping the network, or programmatically aborting).
- Why exploitation is possible: The abort listener tied to the SSE connection invokes
cancelBuildOnDisconnect()using the privileged server-sideBUILDER_API_KEYwithout performing the sameapp.build_nativepermission check enforced by the canonicalPOST /build/cancel/:jobIdendpoint, effectively inverting the intended privilege model.
Why this happens
This issue stems from an authorization check mismatch between two different code paths that both cancel builds.
While the explicit cancellation API enforces an app.build_native permission on the caller, the log-streaming endpoint associates a disconnect event with automatic cancellation and executes it using a highly privileged server-side credential.
Because the disconnect-driven path does not re-evaluate the caller's permissions, read-only API key holders gain access to an effect (build cancellation) that should be reserved for more privileged roles.
This maps to CWE-862: Missing Authorization, where sensitive operations are reachable without the intended authorization checks, often due to hidden control flows such as callbacks, event handlers, or background listeners.
Potential impact
- Attackers with read-only API keys could repeatedly cancel in-progress native builds.
- CI/CD pipelines and automated release workflows may experience instability and unexpected failures.
- Development teams could see delayed releases and decreased reliability of build infrastructure.
- In multi-tenant setups, one tenant might interfere with another tenant's build operations if log access is mis-scoped.
- Increased operational workload as teams attempt to diagnose and restart failed or canceled builds.
General mitigation guidance
Effective mitigation focuses on aligning authorization checks across all control paths that can affect build lifecycle:
- Ensure that any code path capable of canceling a build, including disconnect handlers and internal utilities, performs the same permission checks as the primary cancellation API.
- Avoid using privileged server-side credentials (such as
BUILDER_API_KEY) to perform user-triggered actions without explicitly binding those actions to the caller's authorization context. - Treat logging and observability endpoints as potentially sensitive control surfaces; design them as strictly read-only and avoid coupling them with control-plane actions like cancel or restart.
- Implement fine-grained role and permission models where "view logs" and "cancel build" are distinct, and structure APIs to enforce those distinctions consistently.
- Where possible, adopt secure-by-default patterns such as requiring explicit, authenticated requests for destructive operations rather than inferring them from connection state.
How teams detect issues like this
Detection can combine code-centric and behavior-centric approaches:
- Static analysis and code review: Look for event handlers or disconnect callbacks (e.g.,
onAbort,onDisconnect, SSE or WebSocket listeners) that invoke privileged operations without re-validating the caller's permissions. - Authorization consistency checks: During review, ensure that every way to reach a sensitive operation (like build cancellation) routes through a common authorization layer or shared service that enforces the same policy.
- Logging and telemetry: Instrument build cancellation paths with detailed audit logs that include the originating endpoint, effective permissions, and identity context, then monitor for cancellations initiated from log or observability endpoints.
- Security testing: Use automated tests or security scanners configured to exercise both the official control endpoints and ancillary interfaces (like log viewers) to detect privilege inconsistencies, including forced disconnects and abnormal termination flows.

