- A
Content Security Policy (CSP)
Why wrong: CSP helps mitigate XSS, not CSRF.
- B
CSRF tokens
CSRF tokens are the primary defense against CSRF attacks.
- C
Rate limiting
Why wrong: Rate limiting can slow down brute force attacks but does not prevent CSRF.
- D
Input validation
Why wrong: Input validation helps against XSS and injection, but not CSRF.
Quick Answer
The answer is CSRF tokens, as they are the most effective defense against Cross-Site Request Forgery attacks. These tokens are unique, unpredictable values generated by the server and embedded into each form or request; the server then validates the token before processing the action, ensuring that the request originated from the legitimate user interface rather than a malicious site. Without a valid token, the server rejects the request outright, blocking the attacker even if the victim is authenticated. On the Certified Ethical Hacker CEH exam, this concept tests your understanding of web application security controls, often appearing in questions that contrast CSRF tokens with less reliable defenses like double-submit cookies or referer headers. A common trap is confusing CSRF tokens with session tokens—remember that CSRF tokens are per-request values, not session identifiers. Memory tip: think “Token per action, not per session” to keep the distinction clear.
CEH Web Application and Injection Attacks Practice Question
This CEH practice question tests your understanding of web application and injection attacks. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
Which of the following is the most effective defense against Cross-Site Request Forgery (CSRF) attacks?
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
CSRF tokens
CSRF tokens are the most effective defense because they are unique, unpredictable values embedded in each form or request that the server validates. Without a valid token, the server rejects the request, preventing an attacker from forging a legitimate user's action even if the victim is authenticated.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Content Security Policy (CSP)
Why it's wrong here
CSP helps mitigate XSS, not CSRF.
- ✓
CSRF tokens
Why this is correct
CSRF tokens are the primary defense against CSRF attacks.
Related concept
Read the scenario before looking for a memorised answer.
- ✗
Rate limiting
Why it's wrong here
Rate limiting can slow down brute force attacks but does not prevent CSRF.
- ✗
Input validation
Why it's wrong here
Input validation helps against XSS and injection, but not CSRF.
Common exam traps
Common exam trap: answer the scenario, not the keyword
EC-Council often tests the misconception that input validation or CSP can prevent CSRF, when in fact CSRF exploits the browser's automatic inclusion of credentials (cookies) and requires a server-side token or SameSite cookie attribute to verify request intent.
Detailed technical explanation
How to think about this question
CSRF tokens are typically generated using a cryptographically secure random number generator (e.g., /dev/urandom on Linux) and stored server-side in the session. The token is then included as a hidden field in HTML forms or as a custom header (e.g., X-CSRF-Token) in AJAX requests; the server compares the submitted token against the session-stored value. In real-world scenarios, frameworks like Django or Rails automatically include CSRF tokens, but misconfigurations (e.g., using the same token for all users or failing to invalidate tokens after logout) can still leave applications vulnerable.
KKey Concepts to Remember
- Read the scenario before looking for a memorised answer.
- Find the constraint that changes the correct option.
- Eliminate answers that are true in general but not in this case.
TExam Day Tips
- Watch for words such as best, first, most likely and least administrative effort.
- Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A practitioner preparing for the CEH exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.
What to study next
Got this wrong? Here's your next step.
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
- →
Web Application and Injection Attacks — study guide chapter
Learn the concepts, then practise the questions
- →
Web Application and Injection Attacks practice questions
Targeted practice on this topic area only
- →
All CEH questions
1,010 questions across all exam domains
- →
Certified Ethical Hacker CEH study guide
Full concept coverage aligned to exam objectives
- →
CEH practice test guide
How to use practice tests most effectively before exam day
Related practice questions
Related CEH practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
Footprinting, Reconnaissance and Scanning practice questions
Practise CEH questions linked to Footprinting, Reconnaissance and Scanning.
Enumeration and System Hacking practice questions
Practise CEH questions linked to Enumeration and System Hacking.
Malware, Social Engineering and Network Attacks practice questions
Practise CEH questions linked to Malware, Social Engineering and Network Attacks.
Web Application and Injection Attacks practice questions
Practise CEH questions linked to Web Application and Injection Attacks.
Introduction to Ethical Hacking practice questions
Practise CEH questions linked to Introduction to Ethical Hacking.
Scanning Networks and Enumeration practice questions
Practise CEH questions linked to Scanning Networks and Enumeration.
Vulnerability Analysis and System Hacking practice questions
Practise CEH questions linked to Vulnerability Analysis and System Hacking.
Advanced Topics: Wireless, Cloud, IoT, Cryptography practice questions
Practise CEH questions linked to Advanced Topics: Wireless, Cloud, IoT, Cryptography.
Footprinting and Reconnaissance practice questions
Practise CEH questions linked to Footprinting and Reconnaissance.
Network and Web Application Attacks practice questions
Practise CEH questions linked to Network and Web Application Attacks.
Wireless, IoT and Cloud Security practice questions
Practise CEH questions linked to Wireless, IoT and Cloud Security.
Cryptography and Malware Analysis practice questions
Practise CEH questions linked to Cryptography and Malware Analysis.
Practice this exam
Start a free CEH practice session
Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.
FAQ
Questions learners often ask
What does this CEH question test?
Web Application and Injection Attacks — This question tests Web Application and Injection Attacks — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: CSRF tokens — CSRF tokens are the most effective defense because they are unique, unpredictable values embedded in each form or request that the server validates. Without a valid token, the server rejects the request, preventing an attacker from forging a legitimate user's action even if the victim is authenticated.
What should I do if I get this CEH question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
7 more ways this is tested on CEH
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. Which TWO of the following are effective defenses against CSRF attacks? (Choose 2.)
medium- A.Setting the Secure flag on cookies
- B.Using input validation to block special characters
- ✓ C.Using anti-CSRF tokens that are validated on the server
- ✓ D.Implementing SameSite cookie attribute (Lax or Strict)
- E.Enabling the HttpOnly flag on session cookies
Why C: CSRF tokens and SameSite cookies both prevent cross-site request forgery. Double Submit Cookie is also a method but not listed. Custom headers are not a standard defense; the primary ones are CSRF tokens and SameSite cookies.
Variation 2. Which of the following is the BEST defense against Cross-Site Request Forgery (CSRF) attacks?
easy- A.SameSite cookies
- B.Input validation
- C.Output encoding
- ✓ D.CSRF tokens
Why D: CSRF tokens are unique, unpredictable tokens that validate that requests originate from the legitimate site, effectively mitigating CSRF.
Variation 3. Which of the following is a primary defense mechanism against Cross-Site Request Forgery (CSRF) attacks?
easy- A.Input validation and output encoding
- B.Enforcing CAPTCHA on all forms
- C.Using SameSite cookies
- ✓ D.Implementing CSRF tokens
Why D: CSRF tokens are unique, unpredictable values included in requests that the server validates to ensure the request is intentional. SameSite cookies help but are not the primary defense; CAPTCHA and input validation are not standard CSRF mitigations.
Variation 4. Which of the following is a recommended defense against Cross-Site Request Forgery (CSRF) attacks?
medium- A.Enabling directory listing on the web server
- ✓ B.Implementing CSRF tokens in forms
- C.Using a same-origin policy with CORS headers
- D.Setting the HttpOnly flag on cookies
Why B: CSRF tokens are unique per request and verified by the server, making forged requests invalid without the token.
Variation 5. Which TWO of the following are effective defenses against Cross-Site Request Forgery (CSRF) attacks? (Select 2)
medium- ✓ A.Using anti-CSRF tokens
- ✓ B.Setting the SameSite attribute on cookies
- C.Enabling HTTP Strict Transport Security (HSTS)
- D.Implementing input validation on all user inputs
- E.Using Content Security Policy (CSP) headers
Why A: CSRF tokens are unique per request and validated server-side. SameSite cookies restrict cookie sending to same-site requests.
Variation 6. Which TWO of the following are effective mitigations against Cross-Site Request Forgery (CSRF)?
medium- ✓ A.Using SameSite cookies
- B.Input validation
- C.Using anti-CSRF tokens
- D.Using HTTPOnly cookies
- ✓ E.Using CSRF tokens
Why A: CSRF tokens and SameSite cookies are standard defenses. The other options do not prevent CSRF: input validation does not; anti-CSRF tokens are synonymous; referer header validation is weak.
Variation 7. Which THREE of the following are valid defenses against CSRF attacks? (Select 3)
hard- ✓ A.Custom request headers (e.g., X-Requested-With)
- ✓ B.SameSite cookies set to Lax or Strict
- ✓ C.CSRF tokens
- D.Input validation
- E.Output encoding
Why A: CSRF tokens, SameSite cookies (Lax or Strict), and custom headers (e.g., X-Requested-With with XMLHttpRequest) are all effective CSRF defenses.
Last reviewed: Jun 30, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.