Usage of manual HTML sanitization (XSS)

Description

Sanitizing HTML manually is error prone and can lead to Cross Site Scripting (XSS) vulnerabilities.

Remediations

❌ Avoid manually escaping HTML:

$html = str_replace("&", "&", $text);

✅ Use a HTML sanitizer:

$html = htmlspecialchars($text);

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_manual_html_sanitization

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

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