Usage of vulnerable DOMPurify package

  • Rule ID: javascript_third_parties_dom_purify
  • Languages: javascript
  • Source: dom_purify.yml

Description

For DOMPurify versions less than 2.0.17, there are XSS vulnerabilities when using the sanitize function without proper configuration.

Remediations

  • Do upgrade DOMPurify to version 2.0.17 or greater, and specify a secure configuration option.
      // either
    DOMPurify.sanitize(htmlToSanitize, { RETURN_DOM_IMPORT:true })
    // or
    DOMPurify.sanitize(htmlToSanitize, { RETURN_DOM_FRAGMENT: true })

References

Associated CWE

OWASP Top 10

Configuration

To skip this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --skip-rule=javascript_third_parties_dom_purify

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=javascript_third_parties_dom_purify