Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CWE-87 (替代XSS语法转义处理不恰当) — Vulnerability Class 34

34 vulnerabilities classified as CWE-87 (替代XSS语法转义处理不恰当). AI Chinese analysis included.

CWE-87 represents an input validation weakness where software fails to properly sanitize user-controlled data against alternative script syntaxes, such as HTML entities, Unicode escapes, or embedded scripts within attributes. Attackers typically exploit this flaw by injecting malicious payloads that bypass standard filtering mechanisms, allowing them to execute arbitrary JavaScript in the victim’s browser context. This can lead to severe consequences, including session hijacking, credential theft, or defacement of the web application. To mitigate this risk, developers must implement robust output encoding strategies tailored to the specific context of the data insertion, such as HTML entity encoding for body content or attribute encoding for HTML attributes. Additionally, utilizing comprehensive, well-maintained security libraries and adhering to strict Content Security Policy headers can significantly reduce the attack surface, ensuring that alternate syntax variations are correctly neutralized before rendering.

MITRE CWE Description
The product does not neutralize or incorrectly neutralizes user-controlled input for alternate script syntax.
Common Consequences (1)
Confidentiality, Integrity, AvailabilityRead Application Data, Execute Unauthorized Code or Commands
Mitigations (5)
ImplementationResolve all input to absolute or canonical representations before processing.
ImplementationCarefully check each input parameter against a rigorous positive specification (allowlist) defining the specific characters and format allowed. All input should be neutralized, not just parameters that the user is supposed to specify, but all data in the request, including tag attributes, hidden fields, cookies, headers, the URL itself, and so forth. A common mistake that leads to continuing XSS v…
ImplementationUse and specify an output encoding that can be handled by the downstream component that is reading the output. Common encodings include ISO-8859-1, UTF-7, and UTF-8. When an encoding is not specified, a downstream component may choose a different encoding, either by assuming a default encoding or automatically inferring which encoding is being used, which can be erroneous. When the encodings are i…
ImplementationWith Struts, write all data from form beans with the bean's filter attribute set to true.
ImplementationTo help mitigate XSS attacks against the user's session cookie, set the session cookie to be HttpOnly. In browsers that support the HttpOnly feature (such as more recent versions of Internet Explorer and Firefox), this attribute can prevent the user's session cookie from being accessible to malicious client-side scripts that use document.cookie. This is not a complete solution, since HttpOnly is n…
Effectiveness: Defense in Depth
Examples (1)
In the following example, an XSS neutralization method intends to replace script tags in user-supplied input with a safe equivalent:
public String preventXSS(String input, String mask) { return input.replaceAll("script", mask); }
Bad · Java

Vulnerabilities classified as CWE-87 (替代XSS语法转义处理不恰当) represent 34 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.