fix: Correct missing organization constraint in PromptsActivityEndpoint#104920
Conversation
Co-authored-by: david <david@sentry.io>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: david <david@sentry.io>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #104920 +/- ##
===========================================
+ Coverage 76.05% 80.45% +4.39%
===========================================
Files 9394 9396 +2
Lines 403589 403611 +22
Branches 25904 25904
===========================================
+ Hits 306957 324726 +17769
+ Misses 96197 78450 -17747
Partials 435 435 |
Co-authored-by: david <david@sentry.io>
|
@cursor confirm that the bug exists (as in the test fails if you comment out the test) and then remove the markdown files |
SummaryI've completed both tasks: 1. Confirmed the IDOR bug existsI temporarily removed the security fix from
The fix has been restored and is now in place. 2. Removed the markdown filesDeleted both documentation files:
The changes are ready and show up in Learn more about Cursor Agents |
Co-authored-by: david <david@sentry.io>
|
Cursor Agent can help with this pull request. Just |
|
@cursor remove the 'core' file, and then carefully fix the bug: =========================== FLAKES (original error) ============================ It looks like its an issue with how you setup the fixture - look at similar tests for prior art. |
|
Perfect! I've completed both tasks: 1. Removed the 'core' fileThe core dump file (36MB) has been deleted. 2. Fixed the test bugThe issue in project_id = self.project.id
self.project.delete()
# Then use project_id in the PUT requestThis ensures we're sending a valid integer ID to the endpoint that represents a deleted (non-existent) project, which should correctly trigger the "Project does not belong to this organization" error message instead of "Missing required field". The test now follows the same pattern as similar tests in the codebase where object IDs need to be referenced after deletion. Learn more about Cursor Agents |
Co-authored-by: david <david@sentry.io>
There was a problem hiding this comment.
im kind of curious why/how this works - odd parameter for the endpoint but no idea what the implementation is
| if "project_id" in required_fields: | ||
| if not Project.objects.filter(id=fields["project_id"]).exists(): | ||
| return Response({"detail": "Project no longer exists"}, status=400) | ||
| if not Project.objects.filter( |
There was a problem hiding this comment.
aside this isnt actually a high severity concern afaict, but no idea what the consequence is
|
theres prob more, gonna go find em. |
… organization The GET endpoint accepted project_id in query params but didn't validate it belonged to the organization, allowing users to potentially query prompt activity data using project IDs from other organizations. Added organization scoping check to the GET method (PUT was already fixed in PR #104920) and a regression test for the GET endpoint.
Fixes an IDOR (Indirect Object Reference) vulnerability in the
PromptsActivityEndpoint.Previously, the endpoint allowed users to dismiss prompts for any
project_idas long as it existed, without verifying that the project belonged to the user's organization. This allowed unauthorized prompt dismissals for projects in other organizations.The fix adds
organization_id=request.organization.idto theProject.objects.filterquery when validatingproject_id, ensuring that only projects belonging to the current organization can be referenced. A new regression test has been added, and an existing test updated.