SY0-501 · Question #414
SY0-501 Question #414: Real Exam Question with Answer & Explanation
The correct answer is C: The attacker is replacing a document.. The attacker is using the JavaScript document.location.replace() method to change the current URL, which causes the browser to replace the currently loaded document with another.
Question
An attacker exploited a vulnerability on a mail server using the code below. <HTML><body onload=document.location.replace "URL:" +"document.location) ; /> </body> </HTML> Which of the following BEST explains what the attacker is doing?
Options
- AThe attacker is replacing a cookie.
- BThe attacker is stealing a document.
- CThe attacker is replacing a document.
- DThe attacker is deleting a cookie.
Explanation
The attacker is using the JavaScript document.location.replace() method to change the current URL, which causes the browser to replace the currently loaded document with another.
Common mistakes.
- A. The code snippet does not interact with
document.cookieor any other cookie-specific functions; it targets thelocationobject to change the page URL. - B. Stealing a document would typically involve extracting its content (e.g., via
document.body.innerHTML) or sensitive data and sending it to an attacker-controlled server, not usingdocument.location.replace()for redirection. - D. Deleting a cookie involves manipulating the
document.cookieproperty with an expired date or an empty string, actions not present in the provided code.
Concept tested. Cross-Site Scripting (XSS) document redirection
Reference. https://learn.microsoft.com/en-us/javascript/api/dom/html-dhtml/location
Community Discussion
No community discussion yet for this question.