-
Notifications
You must be signed in to change notification settings - Fork 27
Security: Prevent room ID enumeration #2518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughAdds a "room-enumeration" rate limiter that counts only 404 responses for room-bound routes, applies that throttle to many room-related API endpoints, updates the changelog with the PR, and adds a feature test verifying per-user/IP 404 rate limiting and reset behavior. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
TODO
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2518 +/- ##
=============================================
+ Coverage 96.03% 96.66% +0.63%
- Complexity 1647 1649 +2
=============================================
Files 249 426 +177
Lines 5747 11999 +6252
Branches 0 2063 +2063
=============================================
+ Hits 5519 11599 +6080
- Misses 228 400 +172 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PILOS
|
||||||||||||||||||||||||||||
| Project |
PILOS
|
| Branch Review |
sec-prevent-room-enumeration
|
| Run status |
|
| Run duration | 07m 27s |
| Commit |
|
| Committer | Samuel Weirich |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
599
|
| View all changes introduced in this branch ↗︎ | |
2d96ac3 to
61c5d8e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/Providers/RouteServiceProvider.php (1)
76-89: Limiter design is sound; make limits configurable and verify 'after' semantics
- Counts only 404s when the room param didn’t bind to a Room model. Good approach to avoid false positives.
- Suggest reading limits from config (e.g., perMinutes/attempts), not hard-coded 10/min.
Proposed change:
- RateLimiter::for('room-enumeration', function (Request $request) { - return Limit::perMinute(10) + RateLimiter::for('room-enumeration', function (Request $request) { + $max = config('rate_limits.room_enumeration.max_attempts', 10); + $decay = config('rate_limits.room_enumeration.decay_minutes', 1); + return Limit::perMinutes($decay, $max) ->by($request->user()?->id ?: $request->ip()) ->after(function (\Symfony\Component\HttpFoundation\Response $response) use ($request) { // If the response is not a 404, do not count this request if ($response->getStatusCode() !== 404) { return false; } // Only count the request if the route parameter 'room' was not resolved to a Room model // Prevent counting requests that are valid and return a 404 for other reasons return ! ($request->route('room') instanceof Room); }); });Please confirm the project’s Laravel version supports Limit::after with a boolean return to control counting. If not, we’ll switch to an alternative (e.g., custom middleware with RateLimiter::hit only on 404). Based on learnings
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
CHANGELOG.md(2 hunks)app/Providers/RouteServiceProvider.php(2 hunks)routes/api.php(2 hunks)tests/Backend/Feature/api/v1/Room/RoomTest.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
app/Providers/RouteServiceProvider.php (2)
app/Models/User.php (1)
User(20-349)_ide_helper.php (2)
for(9551-9555)ip(10222-10226)
tests/Backend/Feature/api/v1/Room/RoomTest.php (1)
app/Models/Room.php (2)
Room(19-464)owner(214-217)
routes/api.php (7)
app/Http/Controllers/api/v1/RoomController.php (1)
RoomController(32-426)app/Http/Controllers/api/v1/RoomMemberController.php (1)
RoomMemberController(20-215)app/Http/Controllers/api/v1/RecordingController.php (1)
RecordingController(16-103)app/Http/Controllers/api/v1/RoomStreamingController.php (1)
RoomStreamingController(16-135)app/Http/Controllers/api/v1/RoomTokenController.php (1)
RoomTokenController(17-139)app/Http/Controllers/api/v1/RoomFileController.php (1)
RoomFileController(16-163)app/Http/Controllers/api/v1/RecordingFormatController.php (1)
RecordingFormatController(10-26)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Docker Build
🔇 Additional comments (6)
CHANGELOG.md (2)
13-13: Changelog entry LGTMAccurately reflects the new security feature.
561-561: Reference link added correctlyFootnote for [#2518] is consistent and valid.
tests/Backend/Feature/api/v1/Room/RoomTest.php (1)
419-470: Strong coverage for 404-based throttlingCovers guest vs auth, cross-route blocking, window reset, and excluding valid-room 404s. Nicely done.
routes/api.php (3)
77-137: Throttle scope alignment looks good; confirm intent to block writes after thresholdWrapping all per-room endpoints means once the 404 threshold is exceeded, even valid writes (update/delete, streaming actions, membership ops, etc.) are blocked for the window. This matches the PR note (“all room API calls are blocked”). If that’s intended, LGTM.
164-165: Meetings endpoint throttled consistentlyBrings meetings under the same limiter. Consistent with the threat model.
171-187: Public room routes throttled with auth middleware where neededGood use of room.authenticate and scopeBindings alongside the throttle to keep behavior consistent for guests and users.
88ee280 to
bc9287a
Compare
Type
Checklist
Changes
Other information
All API requests resulting in a 404 response due to an invalid room ID are counted. If the limit exceeds the threshold all room api calls are blocked.
Summary by CodeRabbit
New Features
Documentation
Tests