Skip to main content
Menu
Advisories

Affected component: cipi-sh/api (the REST API package, composer package cipi/api), consumed by this repository and by cipi-sh/gui

GHSA-5QH6-769F-GM4GPublished Updated GitHub

Description

Affected component: cipi-sh/api (the REST API package, composer package cipi/api), consumed by this repository and by cipi-sh/gui. Confirmed on commit 43d43af (branch main) of cipi-sh/api.

Every route in cipi-sh/api's routes/api.php is protected by a Laravel Sanctum ability:<name> middleware matching the operation it performs (for example POST /dbs/{name}/password requires ability:dbs-manage), except one: GET /api/jobs/{id} (handled by JobController::show) sits inside the same auth:sanctum middleware group as every other route but carries no ability: middleware at all, and JobController::show performs no authorization check of its own. CipiJobStatusService::format() returns the full parsed result and raw CLI output of any job once it reaches completed or failed status, with no filtering of what that output contains.

Several privileged operations run through this asynchronous job pipeline and store their result unfiltered in cipi_jobs.output: db password (returns a database's plaintext password), db backup / db restore, app-artisan (returns the full stdout of an arbitrary Artisan command chosen by the caller), and app-run (returns the stdout of a whitelisted app command). Because GET /api/jobs/{id} enforces no ability at all, any valid Sanctum token for the API's single service user, no matter how narrowly it was scoped when created with cipi api token create --abilities=..., can read the result of any job on the server by UUID, including jobs created under abilities that token was never granted. This breaks the confidentiality guarantee of Cipi's own scoped-token model: an operator handing a narrowly-scoped token to a less-trusted integration has no way to prevent that token from reading results produced under a different, more privileged token, once the job UUID becomes known through any channel outside the two tokens' own direct interaction.

Live validation: built a Laravel 12 host application with cipi/api linked via a Composer path repository (the package's own documented integration method), migrated, seeded the service user, and created two Sanctum tokens with the package's own cipi:token-create command: one scoped to dbs-manage,dbs-view and one scoped only to apps-view. Confirmed the apps-view-only token is correctly rejected (403 "Invalid ability provided") attempting POST /api/dbs/{name}/password directly. Using a cipi_jobs row representing a completed db password job's output ("Database: shopdb\nUser: shopdb_user\nPassword: Tr0ub4dor-R0ast-9F2e\n", in the format CipiJobStatusService/CipiOutputParser consume), confirmed the same apps-view-only token successfully retrieves that job's full result and output via GET /api/jobs/{id} (200 OK, password included in both the parsed result object and the raw output string). Confirmed the same request with no token at all correctly returns 401 Unauthenticated, ruling out a missing-authentication explanation and confirming this is specifically a missing-ability-check gap on this one route.

Impact: any valid Sanctum token for a Cipi API instance, regardless of how narrowly it was scoped, can read the full output of any asynchronous job on that server by UUID, bypassing the per-operation ability: checks every other endpoint enforces. This includes database passwords, backup/restore details, and arbitrary command stdout run through the async job pipeline. CWE-862 (Missing Authorization): the route is authenticated but not authorized against the same ability model every sibling endpoint enforces.

Suggested fix: add an ability: middleware to the /jobs/{id} route matching the job's own type field (resolve the ability that originally gated the job's creation and require it on read), or at minimum require the token that created the job to be the one reading it, and strip inherently sensitive fields (db-password output specifically) from what CipiJobStatusService::format() returns to a token lacking the originating ability.

CVSS 3.1: 7.0 (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N)

Affected versions

References

GitHub · cipi-sh/cipi