Skip to content

Sanitize inputs to toast function#2644

Merged
mkultraWasHere merged 1 commit into
masterfrom
xss-op-fix
Aug 19, 2022
Merged

Sanitize inputs to toast function#2644
mkultraWasHere merged 1 commit into
masterfrom
xss-op-fix

Conversation

@argaudreau
Copy link
Copy Markdown
Contributor

Description

String messages to the toast() function were not sanitized, allowing for malicious HTML to be passed to it. In particular, the operation name input in the operations page allowed a user to enter a XSS string such as <img src="http://url.to.file.which/not.exist" onerror=alert(document.cookie);>, which would fire the onerror handler once created.

A sanitize() method has been added so it can be used anywhere in Caldera's UI. It will completely remove any HTML content and return the remaining text, if any. The toast method now uses this, along with a couple of other sections in the operations page.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

After inputing malicious strings to the operation name input, the scripts never fire like they did before.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

@argaudreau argaudreau requested review from a team, mkultraWasHere and yee-jonathan August 17, 2022 13:12
@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@yee-jonathan
Copy link
Copy Markdown
Contributor

Changes correctly sanitize output and prevent execution when using html tags. Even when HTML encoded, malicious scripts will not execute and are displayed as plain text.

@JamieScottC JamieScottC self-requested a review August 19, 2022 19:02
Copy link
Copy Markdown
Contributor

@JamieScottC JamieScottC left a comment

Choose a reason for hiding this comment

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

Confirmed that entering an XSS input doesn't execute any of its malicious behavior.

@mkultraWasHere mkultraWasHere merged commit 31589b7 into master Aug 19, 2022
@mkultraWasHere mkultraWasHere deleted the xss-op-fix branch August 19, 2022 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants