GPEN practice question 11 of 35

John works as a Penetration Tester in a security service providing firm named you-are-secure Inc. Recently, John's company has got a project to test…

Full set: 385 questions
John works as a Penetration Tester in a security service providing firm named you-are-secure Inc. Recently, John's company has got a project to test the security of a promotional Website www.missatlanta.com and assigned the pen-testing work to John. When John is performing penetration testing, he inserts the following script in the search box at the company home page: alert('Hi, John') After pressing the search button, a pop-up box appears on his screen with the text - "Hi, John." Which of the following attacks can be performed on the Web site tested by john while considering the above scenario?
Answer options
A: Replay attack
B: Buffer overflow attack
C: CSRF attack
D: XSS attack Correct answer
Correct Answer:
D. XSS attack
Explanation

The scenario describes a Reflected Cross-Site Scripting (XSS) attack. The tester, John, injects a JavaScript payload into a search field. The web application insecurely includes this script in the immediate response without proper validation or output encoding. When John's browser receives the response, it executes the script because it trusts the content coming from the server. The appearance of the alert box confirms that the application is vulnerable to executing arbitrary client-side scripts within the context of a user's browser session. This vulnerability could be exploited to steal session cookies, deface the site, or redirect users to malicious pages.

Why Incorrect

A. Replay attack: This involves capturing and re-transmitting valid data packets to impersonate a user or repeat a transaction, which is not occurring here.
B. Buffer overflow attack: This is a memory-based attack that involves writing data beyond a buffer's boundary, which is unrelated to injecting and executing a script in a browser.
C. CSRF attack: This attack forges a request from a victim's browser to a web application where they are authenticated, which is different from injecting a script.

References

1. OWASP Foundation. (n.d.). Cross-Site Scripting (XSS). OWASP. Retrieved from https://owasp.org/www-community/attacks/xss/. The "Reflected XSS (Non-Persistent)" section states: "Reflected XSS occurs when an attacker injects executable code into a single HTTP response. The injected attack is not stored within the application itself; it is non-persistent and only impacts users who open a maliciously crafted link or third-party web page." This directly matches the scenario.

2. Saltzer, J. H., & Kaashoek, M. F. (2014). Lecture 15: Web Security. 6.858 Computer Systems Security, Fall 2014. Massachusetts Institute of Technology: MIT OpenCourseWare. Retrieved from https://ocw.mit.edu/courses/6-858-computer-systems-security-fall-2014/resources/mit6858f14lec15/. Slide 10, "Reflected XSS," provides a canonical example of a script injected into a search query parameter (http://host/search?q=<script>...</script>), which is functionally identical to the attack described in the question.

3. Johns Hopkins University. (n.d.). Web Security: XSS and CSRF. Course materials for 601.749: Web and Mobile Security. Retrieved from https://www.cs.jhu.edu/~fabian/courses/CS601.749/slides/04-web-security-xss-csrf.pdf. Slide 11, "Reflected XSS," explains that the "server reflects the attack back to the user's browser" and provides an example using an alert box, mirroring the question's scenario.

Scroll to Top