Exploiting Client-Side Sanitization and Missing HttpOnly Cookies
Short answer
D Launch a Cross-Site Scripting attack to bypass the JavaScript-only sanitization and steal the session cookie that lacks the HttpOnly flag.
Question
Key Takeaways
The question tests whether you can link two clues—client-side-only sanitization and a non-HttpOnly session cookie—to the attack that chains them, with the trap being to pick SQL Injection simply because 'injection' appears in the wording.
This CEH 312-50v12 question presents a web application that sanitizes input only with JavaScript and stores session cookies without the HttpOnly flag. The page establishes that a Cross-Site Scripting (XSS) attack is the matching exploit, because injected script runs in the victim's browser, bypasses client-side filters, and reads the exposed session cookie.
Common mistake: Option B (SQL Injection) is the most common wrong pick because the prompt mentions injection attacks; however, no evidence of unvalidated server-side input or database interaction is given, whereas the missing HttpOnly flag is a textbook XSS session-theft condition.
Expert Analysis
Why the Answer Is Correct
Option D is correct because the two described weaknesses form a classic Stored/Reflected XSS session-hijacking chain. Client-side JavaScript sanitization is enforced in the attacker's target's browser and is trivially bypassed—attacker-controlled script never executes the application's own validation code, and encodings or event handlers can evade naive filters. Once arbitrary script executes in the session's origin, the absence of the HttpOnly flag allows document.cookie to return the session identifier, which the attacker exfiltrates and replays to impersonate the user. EC-Council's CEH material explicitly pairs 'lack of server-side validation + cookies without HttpOnly' with XSS as the exploitation strategy.
Why the Other Options Are Wrong
Option A (DDoS) is a availability attack unrelated to input handling or cookie exposure, and a well-scoped penetration test would not use volumetric overload as the primary technique. Option B (SQL Injection) requires unvalidated server-side input reaching a database query; the prompt only describes client-side JavaScript checks and a cookie flag issue, so it is unsupported speculation. Option C (brute forcing) is inefficient against modern login throttling and does not leverage the specific cookie exposure highlighted in the scenario.
Community Comment Notes
The community vote is unanimous, and the reasoning echoes the analysis: as LordXander put it, "because if there's lack of HttpOnly & validation via JavaScript, this opens the posibility for a XSS to exploit the cookies." insaniunt simply restated option D verbatim as the pick, and one removed comment asked, "Hey friends can we make sure this is correct"—that verification request is answered by the OWASP guidance on XSS prevention and session cookie flags cited below, which confirm D.
Official Reference
- https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
- https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html
These links open the official vendor documentation in a new tab.
Exam Strategy
When a prompt names a client-side control (JavaScript validation) plus a cookie configuration gap (no HttpOnly), the intended answer is almost always XSS-based session theft. Ignore options that require conditions the scenario never states, such as database query flaws for SQLi.
Frequently Asked Questions
Why is SQL Injection wrong when the question mentions preventing injection attacks?
How does the missing HttpOnly flag make XSS worse?
Community Votes
100% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 3 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 3
-
insaniunt 👍 4 Answered DD. Launch a Cross-Site Scripting (XSS) attack, aiming to bypass the client-side sanitization and exploit the exposure of session cookies.
-
LordXander 👍 1 Answered DD - because if there's lack of HttpOnly & validation via JavaScript, this opens the posibility for a XSS to exploit the cookies
-
[Removed] 👍 1Hey friends can we make sure this is correct
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.