XSS Response Write
Untrusted input is written directly into an HTTP response, enabling reflected cross-site scripting (CWE-79) when the response is rendered as HTML. fmt.Fprintf/Fprint and ResponseWriter.Write perform no output encoding.
Standards mapping
- OWASP Top 10
- A03:2021 - Injection
- OWASP ASVS
- V5.3.3 (L1)
Vulnerable vs. safe
fmt.Fprint(w, name)fmt.Fprint(w, html.EscapeString(name))Why it matters & how to fix it
Untrusted input is written directly into an HTTP response, enabling reflected cross-site scripting (CWE-79) when the response is rendered as HTML. fmt.Fprintf/Fprint and ResponseWriter.Write perform no output encoding. Render user data through html/template (which auto-escapes by context), or explicitly HTML-escape with html.EscapeString and set a safe Content-Type.
References
Rule ID integsec-go-xss-response-write - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - Cross-Site Scripting (XSS)DOM XSS Innerhtml Sink
- JavaScript / TypeScript - Cross-Site Scripting (XSS)Reflected XSS Response Tainted Input
- JavaScript / TypeScript - Cross-Site Scripting (XSS)React Dangerously Set Inner HTML
- Go - Cross-Site Scripting (XSS)Text Template For HTML
- Go - Cross-Site Scripting (XSS)XSS Template HTML Bypass
- Ruby - Cross-Site Scripting (XSS)XSS HTML Safe Interpolation