Unsanitized user input detected in raw HTML string.

Description

Applications should not include unsanitized user input in HTML. This can allow cross-site scripting (XSS) attacks.

Remediations

❌ Avoid including user input directly in HTML strings:

$html = "<h1>{$_GET["title"]}</h1>";

✅ Use a templating language such as Twig, and place the template in a separate file.

✅ When HTML strings must be used, sanitize user input:

$html = "<h1>${htmlspecialchars($_GET["title"])}</h1>";

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=php_lang_raw_html_using_user_input

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

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

Ready to take the next step? Learn more about Bearer Cloud.