Safeguard
Application Security•

CWE-87 Alternate XSS Syntax: Unusual Script Forms and Fixes

Script can be written in syntaxes a filter never expected. CWE-87 covers why you canonicalize input and check it against an allowlist.

Safeguard Security Team
2 min read

CWE-87 is a product that does not neutralize user-controlled input for alternate script syntax.

It is a reminder that "script" is not one thing in a browser, and a filter written for the common form can miss the rest.

How it happens

A filter recognizes script tags and a few known patterns. The attacker uses a different syntax the browser also accepts. The record lists one observed example: CVE-2002-0738, XSS using an ampersand, equals sign and a script wrapped in curly braces. See CVE-2002-0738.

The lesson is wider than that one syntax. Any filter that matches a fixed list of forms will miss a form that was not on the list.

What an attacker gains

MITRE lists confidentiality, integrity and availability: reading application data and executing unauthorized code or commands.

How to find it

The record lists no detection methods. Test filters against collections of XSS variants, including unusual syntax, instead of only the common script tag.

How to fix it

  1. Resolve all input to absolute or canonical representations before processing.
  2. Check each parameter against an allowlist of allowed characters and format. Neutralize all data in the request, including tag attributes, hidden fields, cookies, headers and the URL, not only the fields you expect to show. A field that is not reflected today may be reflected by a future developer.
  3. Escape on output for the context where the data lands.

Quick check

Why does an allowlist beat a list of known script forms?

It does not need to know every alternate syntax. Anything outside the allowed characters and format is rejected.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.