Skip to content

Scope the report endpoint prefetch to the requesting user's findings - #15435

Open
svader0 wants to merge 4 commits into
DefectDojo:bugfixfrom
svader0:harden-report-location-finding-scoping
Open

Scope the report endpoint prefetch to the requesting user's findings#15435
svader0 wants to merge 4 commits into
DefectDojo:bugfixfrom
svader0:harden-report-location-finding-scoping

Conversation

@svader0

@svader0 svader0 commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Hardening / consistency improvement to report generation. Reduces a prefetched queryset to the requesting user's authorized scope, matching the check the equivalent path in this module already applies, and threads the user through the three call sites. Adds a regression test.

No functional change for correctly-permissioned users: superusers and in-scope members see exactly what they saw before.

The new test only exercises the Locations code path, so it needs a CI run with that feature enabled.

`prefetch_related_endpoints_for_report` built its prefetched
LocationFindingReference queryset from the whole table. Locations are
deduplicated across products, so the Location queryset's own authorization
check is satisfied by any one associated product, and the findings attached
to a shared Location were not reduced to the caller's scope.

Filter the prefetched references through `get_authorized_findings`, the same
predicate the direct finding routes enforce, and thread the requesting user
through the three call sites. `user=None` resolves to the current user and to
no findings when there is none, so the change fails closed.

The equivalent reduction already exists in the Location branch of
`generate_report`; this brings the widget and product report paths in line.
@dryrunsecurity

dryrunsecurity Bot commented Jul 30, 2026

Copy link
Copy Markdown

DryRun Security

This pull request contains critical findings where files in the sensitive dojo/reports/ directory were modified by an unauthorized author. Specifically, queries.py and widgets.py were changed by 'svader0', who is not on the allowed authors list for this codepath.

🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/reports/queries.py (drs_262707ca)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/reports/queries.py' matches configured sensitive codepath pattern 'dojo/reports/*.py' and was modified by 'svader0' (commit 0fd23e8) who is not in the allowed authors list.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/reports/widgets.py (drs_53237e10)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/reports/widgets.py' matches configured sensitive codepath pattern 'dojo/reports/*.py' and was modified by 'svader0' (commit 0fd23e8) who is not in the allowed authors list.

We've notified @mtesauro.


Comment to provide feedback on these findings.

Report false positive: @dryrunsecurity fp [FINDING ID] [FEEDBACK]
Report low-impact: @dryrunsecurity nit [FINDING ID] [FEEDBACK]

Example: @dryrunsecurity fp drs_90eda195 This code is not user-facing

All finding details can be found in the DryRun Security Dashboard.

svader0 added 3 commits July 30, 2026 15:57
Bare asserts trip ruff S101; unittests/** ignores S105 and S108 but not
S101, and the sibling authorization test uses self.assert* throughout.
The fixture granted product access through Product_Member only. Legacy
authorization reads authorized_users, so the reader was authorized for nothing
and the report rendered none of her own findings. Grant both.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant