SY0-701 Threats, Vulnerabilities, and Mitigations Practice Question
A customer enters `<script>alert('test')</script>` into a public forum signature field. Later, other users who view that signature see the script execute in their browsers. What attack is this?
⚠ Common exam trap
Many exam-takers confuse client-side injection (XSS) with server-side injection (SQL injection) because both involve untrusted input, but XSS targets the browser's rendering engine while SQL injection targets the database query parser.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Cross-site scripting
This is a classic stored cross-site scripting (XSS) attack. The malicious script is injected into a persistent data store (the forum signature field) and later served to other users without proper sanitization, causing the browser to execute the script in the context of the trusted site.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
SQL injection
Why it's wrong here
SQL injection is an attack against the database layer, crafted by inserting SQL metacharacters (e.g., ' OR 1=1--) into input fields to alter query behavior. Entering an 'alert test' script into a public forum does not manipulate a SQL statement; the symptom described is JavaScript executing in another user's browser, which is a client-side effect. A SQL injection would instead cause server-side database errors, data leakage, or query manipulation, not browser-based script execution.
- ✓
Cross-site scripting
Why this is correct
This is a textbook stored cross-site scripting (XSS) attack: the attacker submits JavaScript (such as an 'alert' popup) into a public forum, the server persists it, and when another user views the page, the browser executes the unsanitized script. Because the script runs in the context of the victim's session, it can steal cookies, deface the page, or perform actions on behalf of the user. The 'alert test' is the classic proof-of-concept payload for confirming XSS vulnerabilities.
- ✗
Session replay
Why it's wrong here
Session replay (or session hijacking) requires an attacker to first capture an authenticated session token—via packet sniffing, a man-in-the-middle position, or an XSS cookie stealer—and then reuse that token to impersonate the victim. The scenario here shows the attacker actively submitting a script to a forum, not reusing a captured session identifier. While XSS could be used to steal session cookies and enable replay, the observed symptom is the script execution itself, not the unauthorized reuse of a session.
- ✗
Directory traversal
Why it's wrong here
Directory traversal abuses path handling to reach files, which does not match script injection in a web page.
Go deeper
Related to this question
About these practice questions
One of 1,013 original SY0-701 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
2 more ways this is tested on SY0-701
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A user enters `<script>alert('test')</script>` into a public comment field, and other visitors see the script run in their browsers. What attack is this?
easy- ✓ A.Cross-site scripting
- B.SQL injection
- C.Broken authentication
- D.Insecure deserialization
Why A: This is a classic cross-site scripting (XSS) attack because the user-supplied input containing a script tag is echoed back to other visitors' browsers without proper sanitization or encoding. The script executes in the context of the victim's browser, allowing the attacker to steal cookies, redirect users, or deface the page. XSS exploits the trust a user has for a particular website, unlike SQL injection which targets the database.
Variation 2. A security analyst is investigating a series of alerts from the web application firewall. Users are reporting that when they view a product review page on the company's e-commerce site, their browser automatically redirects to a malicious website. The analyst examines the database and finds that a product review submitted by a user contains a <script> tag that loads a JavaScript file from an external domain. Which type of attack has occurred?
medium- A.Cross-site request forgery (CSRF)
- ✓ B.Stored cross-site scripting (XSS)
- C.SQL injection
- D.Reflected cross-site scripting (XSS)
Why B: The attack is stored cross-site scripting (XSS) because the malicious <script> tag was permanently stored in the product review database. When any user views the product review page, the browser loads and executes the external JavaScript file from the attacker's domain, causing an automatic redirect to a malicious website. This matches the classic stored XSS pattern where payload persists in server-side storage and executes in the victim's browser context.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This SY0-701 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SY0-701 exam.