mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-21 10:15:04 +02:00
fix(security): GHSA-r2qv-8222-hqg3 — allowlist API-key permissions (CVSS 9.9)
API-key permission gates went from a 17-entry admin denylist with the three
documented scope flags (can_read_status / can_queue / can_control_printer)
enforced only inside /api/v1/webhook/* to an explicit per-Permission
allowlist consulted by every dependency:
- core/auth.py: _APIKEY_SCOPE_BY_PERMISSION maps every non-admin
Permission to one scope flag on APIKey; unmapped = 403.
_check_apikey_permissions now takes the api_key and checks the flag.
- require_any_permission_if_auth_enabled + require_ownership_permission
were returning None for any valid key with zero scope check; both now
invoke _check_apikey_permissions and fail closed.
- Two new scope flags on api_keys: can_manage_library (LIBRARY_UPLOAD /
UPDATE_OWN / DELETE_OWN / MAKERWORLD_IMPORT) and can_manage_inventory
(INVENTORY_CREATE / UPDATE / DELETE / FORECAST_WRITE — required by
SpoolBuddy kiosks). Default TRUE, backfilled from can_queue so existing
"queue-only" keys keep working and hardened "read-only" keys do not
silently gain writes.
- CLOUD_AUTH now routed through can_access_cloud for defence-in-depth
alongside the existing _cloud_api_key_gate.
- Migration column-existence check (_api_keys_column_exists) gates the
backfill so user-edited values are never overwritten on restart.
Structural drift backstop: test_every_permission_has_a_classification fails
CI on any new Permission added without an explicit scope mapping —
prevents the denylist-shape regression that grew the prior surface.
Backend 5469 tests green; ruff clean. Frontend build green; i18n parity
green across 9 locales (5005 leaves each, +6 new keys). Wiki permissions
table + allowlist callout + upgrade notes updated.
This commit is contained in:
@@ -988,6 +988,8 @@ export interface APIKey {
|
||||
can_queue: boolean;
|
||||
can_control_printer: boolean;
|
||||
can_read_status: boolean;
|
||||
can_manage_library: boolean;
|
||||
can_manage_inventory: boolean;
|
||||
can_access_cloud: boolean;
|
||||
can_update_energy_cost: boolean;
|
||||
printer_ids: number[] | null;
|
||||
@@ -1002,6 +1004,8 @@ export interface APIKeyCreate {
|
||||
can_queue?: boolean;
|
||||
can_control_printer?: boolean;
|
||||
can_read_status?: boolean;
|
||||
can_manage_library?: boolean;
|
||||
can_manage_inventory?: boolean;
|
||||
can_access_cloud?: boolean;
|
||||
can_update_energy_cost?: boolean;
|
||||
printer_ids?: number[] | null;
|
||||
@@ -1017,6 +1021,8 @@ export interface APIKeyUpdate {
|
||||
can_queue?: boolean;
|
||||
can_control_printer?: boolean;
|
||||
can_read_status?: boolean;
|
||||
can_manage_library?: boolean;
|
||||
can_manage_inventory?: boolean;
|
||||
can_access_cloud?: boolean;
|
||||
can_update_energy_cost?: boolean;
|
||||
printer_ids?: number[] | null;
|
||||
|
||||
Reference in New Issue
Block a user