Scope Tool Product Settings tool selection to authorized tool configurations - #4
Open
svader0 wants to merge 1 commit into
Open
Scope Tool Product Settings tool selection to authorized tool configurations#4svader0 wants to merge 1 commit into
svader0 wants to merge 1 commit into
Conversation
ToolProductSettingsForm offered every Tool_Configuration regardless of the user's permissions, and ToolProductSettingsSerializer (fields="__all__") accepted any tool_configuration id. Tool configurations hold shared third-party credentials gated by view_tool_configuration, so a user who cannot view them must not be able to select or submit one -- via the UI or the REST API. Same authorization gap as the API scan configuration fix (H1 #3900540), lower risk here since tool_product does not replay the credential, but closed for consistency. Scope the form field queryset via get_authorized_tool_configurations(user) (passed from all tool_product views) and validate the same field in the serializer. Reuses the helper added for #3900540. Adds a regression test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
svader0
force-pushed
the
claude/reverent-neumann-ce0eaf
branch
from
July 31, 2026 17:36
3dbffbb to
063f7a1
Compare
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.
Description
ToolProductSettingsFormdeclaredtool_configuration = ModelChoiceField(queryset=Tool_Configuration.objects.all()), andToolProductSettingsSerializerusesfields="__all__", so any user who could reach the Tool Product Settings form or REST endpoint could select or POST anyTool_Configuration— an admin-held third-party credential — regardless of whether they were authorized to view it.Same unscoped-queryset authorization gap that
DefectDojo/django-DefectDojo#15445(H1 #3900540) fixed forProduct_API_Scan_ConfigurationForm. Lower risk here because the tool_product view never runstest_product_connection(no immediate outbound credential replay), but it's the same gap and is closed for consistency.Fix:
ToolProductSettingsForm.__init__(user=...)viaget_authorized_tool_configurations(user)— gates both the rendered choices and the accepted POST value, so narrowing the<select>can't be bypassed by POSTing the id.request.useris passed from all tool_product views (new / edit / delete).tool_configurationinToolProductSettingsSerializer(PATCH-safe: no-op when the field is absent) so the REST endpoint is gated too.get_authorized_tool_configurationshelper introduced in Scope API scan configuration tool selection to authorized tool configurations DefectDojo/django-DefectDojo#15445;dojo/tool_config/queries.pyis included here identically so this branch is self-contained and merges cleanly with it.Test results
Adds
unittests/test_tool_product_settings_tool_authz.py, mirroringtest_api_scan_configuration_tool_authz.py: an unprivileged user is offered no configurations, cannot submit a config id (form and REST both reject), and a privileged user still can. Not run locally (the running stack mounts a different checkout); executes in CI.Documentation
None needed — internal authorization fix, no behavior change for authorized users.
Checklist
bugfixbranch (bug fix).