Safeguard
Application Security•

CWE-85 Doubled Character XSS: Why One-Pass Filters Fail

Doubling a character can sneak script past a filter that removes it once. CWE-85 shows why you canonicalize first and use allowlists.

Safeguard Security Team
2 min read

CWE-85 is a web application that does not filter user-controlled input for executable script disguised by doubling the characters involved.

It affects code that tries to clean input by removing or replacing a bad pattern once.

How it happens

A filter strips a dangerous string a single time. The attacker doubles the characters, so that what remains after the strip is still the dangerous string. Or the attacker adds an extra character that the filter ignores but the browser tolerates.

The observed examples show the variety: CVE-2002-2086 is XSS using a doubled script tag opener, CVE-2000-0116 is an encoded "javascript" in an image tag and CVE-2001-1157 is an extra opening angle bracket in front of a script tag. See CVE-2002-2086, CVE-2000-0116 and CVE-2001-1157.

# Vulnerable: one pass only
clean = user_input.replace("javascript:", "")
# "javajavascript:script:" becomes "javascript:"

What an attacker gains

MITRE lists confidentiality, integrity and availability: reading application data and running unauthorized code or commands in the victim's session.

How to find it

The record lists no detection methods. Test filters with doubled and padded variants of every pattern they remove.

How to fix it

  1. Resolve filtered input to absolute or canonical representations before processing.
  2. Check each parameter against an allowlist of allowed characters and format, covering all request data, including tag attributes, hidden fields, cookies, headers and the URL.
  3. Do not strip and trust. If something dangerous is found, reject the input instead of repairing it.

Quick check

Why does removing a pattern once fail?

The leftover characters can join to form the same pattern again after the removal.

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.