fix: add missing ownership checks in projects API (GHSA-rpf3-3973-4gjr)#12462
Conversation
… read (GHSA-rpf3-3973-4gjr) Prevent authenticated users from reassigning flows they don't own by adding `Flow.user_id == current_user.id` to the UPDATE statements in `create_project`. Also fix the paginated path in `read_project` which was missing the same filter, allowing cross-user flow exfiltration via the `?page=&size=` query parameters.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (40.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## release-1.9.0 #12462 +/- ##
=================================================
+ Coverage 51.83% 52.01% +0.17%
=================================================
Files 2007 2004 -3
Lines 181207 181815 +608
Branches 27099 28337 +1238
=================================================
+ Hits 93931 94572 +641
+ Misses 86226 86193 -33
Partials 1050 1050
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Cristhianzl
left a comment
There was a problem hiding this comment.
Please add test in your PR.
TESTING
Coverage Requirements
- No tests included in this PR
This is a CRITICAL gap for a security fix. The PR description includes a test plan but no automated tests.
Required tests:
-
Test: attacker cannot steal victim's flow via
create_project- User A creates a flow
- User B creates a project with
flows_list: [user_a_flow_id] - Assert: User A's flow
folder_idis unchanged - Assert: User B's project contains 0 flows
-
Test: paginated
read_projectdoes not leak other users' flows- Setup: project with flows from two different users
- Assert:
GET /projects/{id}?page=1&size=50returns only current user's flows
-
Test: attacker cannot steal victim's flow via
update_project(for the finding above) -
Test:
download_filedoes not include other users' flows (for the finding above)
Result: FAIL — security fixes MUST have regression tests.
- test_create_project_cannot_steal_other_users_flow: asserts that
flows_list in create_project does not move flows owned by another user
- test_read_project_paginated_does_not_leak_other_users_flows: asserts
that paginated GET /projects/{id} only returns flows owned by the
requesting user
…ecks Remove advisory IDs from test names and docstrings, rename helper and test functions to match the existing codebase conventions.
…r) (#12462) * fix: enforce ownership check on flow assignment and paginated project read (GHSA-rpf3-3973-4gjr) Prevent authenticated users from reassigning flows they don't own by adding `Flow.user_id == current_user.id` to the UPDATE statements in `create_project`. Also fix the paginated path in `read_project` which was missing the same filter, allowing cross-user flow exfiltration via the `?page=&size=` query parameters. * test: add security regression tests for GHSA-rpf3-3973-4gjr - test_create_project_cannot_steal_other_users_flow: asserts that flows_list in create_project does not move flows owned by another user - test_read_project_paginated_does_not_leak_other_users_flows: asserts that paginated GET /projects/{id} only returns flows owned by the requesting user * test: improve security test naming and style for project ownership checks Remove advisory IDs from test names and docstrings, rename helper and test functions to match the existing codebase conventions. * [autofix.ci] apply automated fixes * fix: address ruff linting errors in ownership security tests * test: add coverage for legitimate flows_list and paginated read assignments --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Carlos Coelho <80289056+carlosrcoelho@users.noreply.github.com>
Summary
Fixes GHSA-rpf3-3973-4gjr — authenticated users could reassign flows they don't own into their project, exfiltrate the flow data via paginated API, and cause the victim to lose access to their flow.
Root cause — two missing ownership checks in
projects.py:POST /api/v1/projects/:flows_listandcomponents_listwere applied viaUPDATEwithout verifyingFlow.user_id == current_user.id, allowing any user to move another user's flow into their own projectGET /api/v1/projects/{id}?page=&size=: the paginated code path fetched flows with nouser_idfilter, leaking flows belonging to other usersFix: add
Flow.user_id == current_user.idto bothUPDATEstatements increate_projectand to the paginatedSELECTinread_project.Attack chain
flows_list: [victim_flow_id]GET /api/v1/projects/{attacker_project_id}?page=1&size=50and receives the victim's full flow dataTest plan
flows_list: [victim_flow_id]→ project must be created emptyfolder_idmust remain unchangedGET /api/v1/projects/{attacker_project_id}?page=1&size=50must return 0 flows