Skip to content

Escape javascript breaking on backlash or special characters in finding title#12514

Merged
Maffooch merged 5 commits into
DefectDojo:bugfixfrom
c-goosen:fix-finding-title-special-characters
May 29, 2025
Merged

Escape javascript breaking on backlash or special characters in finding title#12514
Maffooch merged 5 commits into
DefectDojo:bugfixfrom
c-goosen:fix-finding-title-special-characters

Conversation

@c-goosen

@c-goosen c-goosen commented May 27, 2025

Copy link
Copy Markdown
Contributor

Escape javascript breaking on backlash or special characters in finding title

Description

Fixes: #12512

A backslash in finding title breaks frontend render in list view.

Test results

Ideally you extend the test suite in tests/ and dojo/unittests to cover the changed in this PR.
Alternatively, describe what you have and haven't tested.

@valentijnscholten

Copy link
Copy Markdown
Member

@c-goosen Thank you for reporting and fixing! Could you look at the Ruff failures? It looks like you added some noqa's to fix Ruff errors but now it complains there was nothing to fix 🤔

@c-goosen c-goosen marked this pull request as ready for review May 28, 2025 12:39
@dryrunsecurity

Copy link
Copy Markdown

DryRun Security

🔴 Risk threshold exceeded.

This pull request involves sensitive edits to a template file with potential cross-site scripting (XSS) risks and input validation concerns, which may require careful review of escaping mechanisms and input handling to prevent potential security vulnerabilities.

⚠️ Configured Codepaths Edit in dojo/templates/dojo/filter_js_snippet.html
Vulnerability Configured Codepaths Edit
Description Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.
💭 Unconfirmed Findings (2)
Vulnerability Potential Cross-Site Scripting (XSS) Risk Without Escaping
Description Located in dojo/templates/dojo/filter_js_snippet.html, this vulnerability involves direct insertion of words into JavaScript arrays without escaping, which could potentially allow XSS attacks by executing malicious scripts if special characters are present.
Vulnerability Potential Input Validation Bypass with Special Characters
Description Found in tests/finding_test.py, this issue suggests possible insufficient input validation for special characters in finding titles, with the test indicating the application can handle backslash characters, which might reveal input validation weaknesses.

We've notified @mtesauro.


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

@c-goosen

c-goosen commented May 28, 2025

Copy link
Copy Markdown
Contributor Author

@c-goosen Thank you for reporting and fixing! Could you look at the Ruff failures? It looks like you added some noqa's to fix Ruff errors but now it complains there was nothing to fix 🤔

Thanks fixed that.
Also did some more testing locally with our own data imported to docker-compose local dev.

Local tested before with our data:
Screenshot 2025-05-28 at 14 42 43

After fix:
Screenshot 2025-05-28 at 14 39 18

Just to be careful I tested inputs like a XSS payload getting injected, but the escapejs jinja2 argument is escaping the content correctly.

Screenshot 2025-05-28 at 14 58 37

@mtesauro @Maffooch ready for review.

Comment thread tests/finding_test.py
@valentijnscholten valentijnscholten added this to the 2.47.0 milestone May 28, 2025
@manuel-sommer

manuel-sommer commented May 28, 2025

Copy link
Copy Markdown
Contributor

Could you also look at #11572 and #11408 @c-goosen if these are fixed with this PR?

@Maffooch Maffooch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to reproduce the issue where findings could not be displayed, but there was a bunch of browser console errors that this fixes

@Maffooch Maffooch requested a review from blakeaowens May 29, 2025 19:04
@Maffooch Maffooch merged commit 33559eb into DefectDojo:bugfix May 29, 2025
76 of 77 checks passed
@manuel-sommer

Copy link
Copy Markdown
Contributor

Can we now also close #11572 and #11408 ?

@valentijnscholten

Copy link
Copy Markdown
Member

Can we now also close #11572 and #11408 ?

The PR here only changed the population of the words list in the filter section. Displaying of finding titles was not affected.

@c-goosen

Copy link
Copy Markdown
Contributor Author

Can we now also close #11572 and #11408 ?

The PR here only changed the population of the words list in the filter section. Displaying of finding titles was not affected.

@valentijnscholten && @manuel-sommer I only changed the generation of the javascript file, didn't touch the HTML templates. I can look at what we would need to fix the two issues as well.

xansec pushed a commit to xansec/django-DefectDojo that referenced this pull request Jun 18, 2025
…ng title (DefectDojo#12514)

* Escape javascript breaking on backlash or special characters in finding titel

* Ruff formatting and W605 ignore

* Fix escape character issue with \

* Remove ruff noqa comments.

* Fix ruff failure on w291
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.

6 participants