CEH Web Application and Injection Attacks Practice Question
A web developer wants to mitigate CSRF attacks. Which of the following configurations for cookies is most effective when combined with CSRF tokens?
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
✓
SameSite=Strict
SameSite=Strict prevents the browser from sending cookies for cross-site requests, which blocks CSRF attacks.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
HttpOnly flag
Why it's wrong here
The HttpOnly flag prevents client-side scripts, such as JavaScript, from accessing the cookie. While crucial for mitigating Cross-Site Scripting (XSS) attacks by preventing cookie theft, it does not prevent a browser from automatically attaching the cookie to a cross-site request initiated by a malicious site. Therefore, it offers no direct protection against Cross-Site Request Forgery (CSRF), as CSRF exploits the browser's default behavior of sending cookies with requests.
- ✓
SameSite=Strict
Why this is correct
The SameSite=Strict attribute is a powerful defense against CSRF attacks by instructing the browser to only send the cookie with requests originating from the same site as the cookie's domain. This means if a user is logged into `example.com` and then visits `malicious.com`, any requests `malicious.com` attempts to make back to `example.com` will not include the session cookie. Consequently, the malicious request will not be authenticated, effectively preventing the forgery.
- ✗
Domain attribute
Why it's wrong here
The Domain attribute specifies which hosts are permitted to receive the cookie, defining its scope to a particular domain or its subdomains. For instance, setting `Domain=example.com` allows `sub.example.com` to receive the cookie. However, this attribute does not dictate whether a cookie should be sent with a cross-site request, only where it can be sent. Thus, it provides no inherent protection against CSRF attacks.
- ✗
Secure flag
Why it's wrong here
The Secure flag ensures that a cookie is only transmitted over encrypted HTTPS connections, protecting it from interception by passive network attackers. While vital for preventing man-in-the-middle attacks and ensuring confidentiality, it does not prevent the browser from sending the cookie in a cross-site request if that request is also made over HTTPS. Therefore, it does not mitigate the core mechanism of CSRF, which relies on an authenticated user's browser making an unintended request.
Go deeper
Related to this question
About these practice questions
One of 870 original CEH 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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CEH practice question is part of Courseiva's free EC-Council 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 CEH exam.