Fix/rbac sensor create hardening#120
Closed
bhudevbhanpuriya wants to merge 1 commit into
Closed
Conversation
1a2bf61 to
4e6e5da
Compare
Contributor
Author
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.
Summary
This PR fixes an access control gap in the
POST /Sensorsendpoint by introducing explicit RBAC enforcement at the API layer and adding regression tests to validate correct behavior.Previously, low-privilege users (e.g., viewers) could reach the sensor creation flow without a strict endpoint-level authorization check.
Problem
The sensor creation endpoint did not enforce a clear role-based allow-list.
Authorization depended on downstream behavior, which could allow unintended access and lead to inconsistent enforcement.
As a result, users with insufficient privileges could potentially create sensor entities.
Root Cause
Missing explicit RBAC validation at the endpoint level for the
CREATE_SENSORoperation.The system relied on implicit or indirect checks instead of enforcing a deterministic authorization gate.
Changes
POST /SensorsBehavior before v after
sequenceDiagram title RBAC Fix: Prevent Viewer from Creating Sensor participant U as User (Viewer) participant API as API Server participant RBAC as RBAC Check participant DB as Database U->>API: POST /Sensors API->>API: Validate Token (Viewer) alt BEFORE (Bug - Missing RBAC) Note right of API: No role check API->>DB: Insert Sensor DB-->>API: Success API-->>U: 201 Created ❌ else AFTER (Fixed - RBAC enforced) API->>RBAC: Check CREATE_SENSOR RBAC-->>API: Denied API-->>U: 403 Forbidden ✅ endWhy This Matters
Testing
pytestBackward Compatibility
Future Improvements (Optional)
Solves #119