Skip to content

Commit

Permalink
[login] Add code sanitizer before dangerouslySetInnerHTML (#7491)
Browse files Browse the repository at this point in the history
This adds DOMPurify to sanitize the code that is passed through dangerouslySetInnerHTML to avoid XSS vulnerabilities.
  • Loading branch information
CamilleBeau authored Nov 30, 2022
1 parent 5ee4259 commit b932880
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/#/jsx/#Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, {Component} from 'react';
import PropTypes from 'prop-types';
import Loader from 'Loader';
import Panel from 'Panel';
import DOMPurify from 'dompurify';

/**
* Login form.
Expand Down Expand Up @@ -177,7 +178,9 @@ class Login extends Component {
}
if (this.state.mode === 'login') {
const study = (
<div dangerouslySetInnerHTML={{__html: this.state.study.description}}/>
<div dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(this.state.study.description),
}}/>
);
const error = this.state.form.error.toggle ? (
<StaticElement
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@babel/runtime": "^7.10.5",
"@fortawesome/fontawesome-free": "^5.11.2",
"copy-webpack-plugin": "^11.0.0",
"dompurify": "^2.2.9",
"jstat": "^1.9.5",
"papaparse": "^5.3.0",
"prop-types": "^15.7.2",
Expand Down

0 comments on commit b932880

Please # to comment.