Reflected cross-site scripting (XSS)

ID

vbnet.inject.cross_site_scripting

Severity

high

Remediation Complexity

medium

Remediation Risk

medium

Remediation Effort

medium

Resource

Inject

Language

VB.NET

Description

User-controlled input flows into an HTML response without output encoding, which may allow reflected cross-site scripting (XSS). Encode the value for the HTML context before writing it (e.g. Server.HtmlEncode / HttpUtility.HtmlEncode / AntiXss.HtmlEncode), or bind it through a control that auto-encodes.

Rationale

User-controlled input flows into an HTML response without output encoding, which may allow reflected cross-site scripting (XSS). Encode the value for the HTML context before writing it (e.g. Server.HtmlEncode / HttpUtility.HtmlEncode / AntiXss.HtmlEncode), or bind it through a control that auto-encodes.

The following code illustrates a vulnerable pattern detected by this rule:

Public Sub WriteQueryString()
    ' VULNERABLE: Reflected cross-site scripting (XSS)
    Response.Write(Request.QueryString("name"))
End Sub

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.