Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Many applications that accept untrusted input strings employ input filtering and validation mechanisms based on the strings' character data. For example, an application's strategy for avoiding cross-site scripting (XSS) vulnerabilities may include forbidding <script> tags in inputs. Such blacklisting mechanisms are a useful part of a security strategy, even though they are insufficient for complete input validation and sanitization. When implemented, this form of validation must be performed only after normalizing the input.

...

Code Block
bgColor#ccccff
String s = "\uFE64" + "script" + "\uFE65";

// Normalize
s = Normalizer.normalize(s, Form.NFKC);

// Validate
Pattern pattern = Pattern.compile("[<>]");
Matcher matcher = pattern.matcher(s);
if (matcher.find()) {
  // Found blackblacklisted listed tag
  throw new IllegalStateException();
} else {
  // ...
}

...

Validating input before normalization affords attackers the opportunity to bypass filters and other security mechanisms. This It can result in the execution of arbitrary code.

...

ToolVersionCheckerDescription
Fortify1.0

Process_Control

Implemented

Related Guidelines

ISO/IEC TR 24772:20102013

Cross-site scripting Scripting [XYT]

MITRE CWE

CWE-289. , Authentication bypass by alternate name 
CWE-180. , Incorrect behavior order: Validate before canonicalize

...