Unsanitized user input in HTTP response (XSS)

Description

Including unsanitized user input in HTTP responses exposes your application to cross-site scripting (XSS) attacks. This vulnerability allows attackers to inject malicious scripts into web pages viewed by other users.

Remediations

  • Do not include user input directly in a response. This practice can lead to XSS vulnerabilities.
  func bad(w http.ResponseWriter, r *http.Request) {
userInput := r.URL.Query().Get("input")
fmt.Fprintf(w, "<html><body>%s</body></html>", userInput)
}

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

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

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