Repository navigation
Conversation
…= cannot 500 GET/HEAD /api/v2/oa3/schema/?version=<CR/LF> returned 500 with django.http.response.BadHeaderError. drf-spectacular interpolates the attacker-controlled ?version= query parameter into the Content-Disposition filename unsanitized, and Django refuses header values containing CR/LF. The header injection never actually succeeds, but each scanner probe produced an unhandled 500 and a diagnostics error report. Override DojoSpectacularAPIView._get_filename to strip CR, LF and the quote delimiter from the filename, so the response header is always well formed whatever ?version= contains. The Pro SerializedSpectacularAPIView subclass inherits this with no extra change. Add a regression test. Refs DefectDojo-Inc/dojo-pro#6013 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013r7wUwFigkbymmti9TLSmL
|
This pull request modifies a sensitive codepath in
Configured Sensitive Codepath Modified by Non-Allowed Author in
|
| Vulnerability | Configured Sensitive Codepath Modified by Non-Allowed Author |
|---|---|
| Description | File 'dojo/api_v2/views.py' matches configured sensitive codepath pattern 'dojo/api_v2/*.py' and was modified by 'claude' (commit cfebf13) who is not in the allowed authors list. |
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.
This branch has not been deployed
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
Refs DefectDojo-Inc/dojo-pro#6013
The bug
GET/HEAD/api/v2/oa3/schema/?format=json&version=<CR/LF payload>returns a 500:drf-spectacular interpolates the
versionvalue into theContent-Dispositionfilename without sanitizing it.
versionis attacker-controlled (the?version=query parameter; no versioning class is configured, so the raw value flows through),
and Django refuses to set a header value containing CR/LF — so building the response
raises
BadHeaderError.The header injection itself never succeeds (Django's rejection is exactly what
stops it), but the unhandled exception surfaces as an unauthenticated 500 on a public
endpoint, and each scanner probe generates an error report. It is a crash/noise bug,
not a successful injection.
The fix
Override
DojoSpectacularAPIView._get_filenameto strip CR, LF and the double-quotedelimiter from the filename before it reaches the header, so the
Content-Dispositionheader is always well formed whatever
?version=(or any DRF versioning scheme)produces. A legitimate
?version=v2is unaffected (the schema is served normally; thefilename just carries
v2).Tests
unittests/test_apiv2_oa3_schema.py:?version=now returns 200 with no CR/LF inContent-Dispositionand noinjected header (fails on
dev— the request raisesBadHeaderError);?version=v2is still served.Impact on DefectDojo Pro
Pro serves the same endpoint through
SerializedSpectacularAPIView, which subclassesDojoSpectacularAPIViewand only overridesget()(to hold a generation lock),delegating to
super(). It does not override_get_filename, so it inherits this fixwith no Pro-side change — the Pro
/api/<schema>/schema/endpoints are covered too.Verification note
Prepared in a cloud session without a Docker daemon, so the containerised test suite
was not run locally; CI runs it. The crash and the fix were confirmed in an isolated
reproduction: feeding the raw
versioninto a Django response header raises the exactBadHeaderError: Header values can't contain newlines, and the sanitized filename setsthe header cleanly with no CR/LF.
ruff check(pinned 0.16.10, the repo config) passeson both changed files.
Generated by Claude Code