Refactor get_object_or_404 calls for Engagement and Engagement_Presets#14375
Merged
Refactor get_object_or_404 calls for Engagement and Engagement_Presets#14375
Conversation
valentijnscholten
approved these changes
Feb 24, 2026
…tering with engagement
…date_benchmark_summary functions
🟡 Please give this pull request extra attention during review.This pull request introduces a view that can allow IDOR: the updated answer_questionnaire view in dojo/survey/views.py only ensures the survey belongs to the engagement but still allows access to the engagement via user-provided IDs when allow_anonymous_survey_repsonse is enabled, letting unauthenticated users guess engagement and survey IDs to read/modify surveys — unlike other views protected by @user_is_authorized.
🟡 Potential IDOR Vulnerability in
|
| Vulnerability | Potential IDOR Vulnerability |
|---|---|
| Description | The 'answer_questionnaire' view in 'dojo/survey/views.py' retrieves both an Engagement and an Answered_Survey using user-supplied integer IDs (eid and sid) without proper, non-bypassable authorization. While the patch adds a check to ensure the survey belongs to the specified engagement ('survey = get_object_or_404(Answered_Survey.objects.filter(engagement=engagement), id=sid)'), the 'engagement' itself is only authorized if 'allow_anonymous_survey_repsonse' is disabled. If this setting is enabled, any user (including unauthenticated ones) can access and modify any survey by guessing its auto-incrementing ID and the associated engagement ID. In contrast, other views in the same file are protected by the '@user_is_authorized' decorator, which enforces strict permission checks on the engagement before the view logic is executed. |
django-DefectDojo/dojo/survey/views.py
Lines 100 to 103 in f1f3b93
All finding details can be found in the DryRun Security Dashboard.
Jino-T
approved these changes
Feb 25, 2026
blakeaowens
approved these changes
Feb 26, 2026
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.
Optimize the
get_object_or_404calls to filter Engagement and Engagement_Presets by their respective relationships, improving data retrieval efficiency. This change enhances the integrity of the data being accessed in the views.