fix(security): add RBAC permission checks to all device API endpoints#361
Merged
robotlearning123 merged 1 commit intomainfrom Mar 28, 2026
Merged
fix(security): add RBAC permission checks to all device API endpoints#361robotlearning123 merged 1 commit intomainfrom
robotlearning123 merged 1 commit intomainfrom
Conversation
f7fff2a to
86c8ec9
Compare
2c595ff to
2f5372b
Compare
All 5 device endpoints (heartbeat, list, get, update, mark-offline) had zero authentication. Any user could: - Spoof heartbeats to inject fake devices or overwrite IPs - List/get all device records (info leak) - Update device metadata (arbitrary writes) - Mark devices offline (denial of service) Fix: add require_permission() dependency to each endpoint: - heartbeat, update, offline: manage_devices (new permission) - list, get: view_equipment (existing) - Added manage_devices to ALL_PERMISSIONS (PI/admin get it) 5 new auth-gate tests verify 401 on all endpoints when auth enabled.
2f5372b to
f5420fd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
All 5 device API endpoints (
/api/v1/devices/) had zero authentication/authorization checks. Any user (including visitors) could:Root Cause
The
devices.pyroute module was added withoutrequire_permission()dependency injection, unlike all other route modules (equipment, orders, vendors, etc.).Fix
from lab_manager.api.auth import require_permissionimportdependencies=[Depends(require_permission(...))]to all 5 endpoints:POST /heartbeat→manage_devicesGET /→view_equipmentGET /{id}→view_equipmentPATCH /{id}→manage_devicesPOST /{id}/offline→manage_devicesmanage_devicestoALL_PERMISSIONSin auth.pyTest
🤖 Found and fixed by bug-hunter autonomous loop (cycle 47).