112-57 practice question 6 of 15

Given below is a regex signature used by security professionals for detecting an XSS attack: /((%3C)|)/i Which of the following types of XSS attack does the above regex expression detect?

Full set: 75 questions
Answer options
A: HTML tags-based XSS attempt Correct answer
B: CSS attack
C: Simple XSS attack
D: In-line comment XSS attack
Correct Answer:
A. HTML tags-based XSS attempt
Explanation

The provided regular expression, /((%3C)|)/i, is specifically constructed to detect the fundamental structure of an HTML tag. It identifies a string that begins with either a literal less-than sign () or its encoded form (%3E). Since Cross-Site Scripting (XSS) attacks commonly involve injecting malicious code encapsulated within HTML tags (e.g., <script>, , ), this regex signature is a primary method for identifying such attempts. The /i flag makes the pattern case-insensitive, broadening its detection capability.

Why Incorrect

B. CSS attack: This regex does not target the specific syntax of CSS-based attacks, such as expression() or @import, which follow different patterns.
C. Simple XSS attack: This term is too vague and not a standard classification. The regex targets a specific vector (HTML tags), making option A more precise.
D. In-line comment XSS attack: The regex is not designed to match the distinct structure of an HTML comment, which is .

References

1. OWASP Foundation. "XSS Filter Evasion Cheat Sheet." OWASP. Accessed May 23, 2024. The document extensively discusses methods to bypass filters that look for HTML tag characters like , confirming that detecting these characters is a fundamental, signature-based approach to preventing HTML tag-based XSS.

2. Vogt, P., Nentwich, F., Jovanovic, N., Kirda, E., Kruegel, C., & Vigna, G. (2007). "Cross-site scripting prevention with dynamic data tainting and static analysis." In Proceedings of the 14th Annual Network and Distributed System Security Symposium (NDSS'07). This paper discusses XSS prevention techniques, where the foundational detection method often involves identifying and sanitizing HTML metacharacters like , which the provided regex targets (Section 2.1, Background on XSS).

3. Johns, M. (2006). "An Introduction to Cross-Site Scripting (XSS)." SANS Institute InfoSec Reading Room. This SANS whitepaper explains that a common defense is to filter user input for HTML tags, which involves looking for the characters, the exact pattern matched by the given regex (Page 6, "Filtering User Input").

Scroll to Top