Remediated mark_safe calls to prevent XSS attacks. #734
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.
ColdFront XSS Exploit
Steps to Reproduce
<b>This is where the text is.<b> <script>alert("Malicious ! slurm ! Script")</script>
.How this Happened
The function
get_information
incoldfront.core.allocation.models
uses normal string formatting to create a string from data in the database and then uses themark_safe
function before passing it on. This was done because each string returned fromget_information
needed to include a<br>
element. However, themark_safe
function will make it so that the string is interpreted as a safe HTML string to render, bypassing Django's built-in XSS protections in templates. This leads to the XSS attack when any of the values pulled from th database contain HTML.In this instance, whenever a value was specified by a user for an AllocationAttribute whose AllocationAttributeType was in the setting ALLOCATION_ATTRIBUTE_VIEW_LIST, that value would be sent to the user as raw HTML. There are calls made to
get_information
in the HTML filesproject_detail.html
anduser_list_allocations.html
which are vulnerable to this attack. Since the fileuser_list_allocations.html
uses theget_information
with the following templating condition:it will only be vulnerable when the string
"slurm"
is also included in the injection.There is another call to
get_information
inside theallocation_request_list.html
file but this does not appear to be vulnerable to this attack.