Unsanitized user input in dynamic HTML insertion (XSS)

Description

There are XSS vulnerabilities when dynamically inserting HTML that contains unsanitized data.

Remediations

Make sure you use HTML sanitization library before inserting html

import sanitizeHtml from 'sanitize-html';

const html = `<strong>${user.Input}</strong>`;
document.body.innerHTML = sanitizeHtml(html)

Resources

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_lang_dangerous_insert_html

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

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