Courseiva
Web Application and Injection AttackshardMultiple SelectObjective-mapped

CEH Web Application and Injection Attacks Practice Question

Which THREE of the following are effective mitigation techniques against Cross-Site Scripting (XSS) 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

Output encoding

Input validation ensures malicious characters are rejected. Output encoding converts special characters to safe HTML entities. Content Security Policy (CSP) restricts script sources. Disabling JavaScript is not practical. Using HTTPS protects data in transit but not against XSS.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Output encoding

    Why this is correct

    When user-supplied data is rendered back to a client, output encoding converts special characters (like <, >, &, ", ') into their entity equivalents (e.g., &lt;, &gt;). This process prevents the browser from interpreting these characters as active content or HTML tags, effectively neutralizing any embedded malicious scripts and ensuring they are displayed as harmless text rather than executed.

  • Implementing Content Security Policy (CSP)

    Why this is correct

    Content Security Policy (CSP) is a powerful browser-side security mechanism that allows web administrators to define trusted sources of content (scripts, stylesheets, images, etc.) through HTTP headers. By specifying directives like script-src 'self', CSP instructs the browser to only execute scripts originating from the same domain, thereby preventing the execution of injected malicious scripts from untrusted sources, even if they manage to bypass input validation and output encoding.

  • Disabling JavaScript in the client browser

    Why it's wrong here

    While disabling JavaScript in the client browser would prevent the execution of most XSS payloads, it is not a practical or effective mitigation technique for web application developers. This approach severely degrades user experience by breaking essential website functionality, places the burden on the end-user, and does not address the underlying vulnerability on the server or application side that allows script injection in the first place.

  • Using HTTPS for all communications

    Why it's wrong here

    HTTPS provides encryption for data in transit, ensuring confidentiality and integrity between the client and server by preventing eavesdropping and tampering. However, HTTPS does not protect against XSS attacks, which exploit vulnerabilities in how a web application processes and renders user-supplied data. An XSS payload, even if delivered over an encrypted channel, will still execute if the application fails to properly validate input or encode output.

  • Input validation

    Why this is correct

    Input validation involves rigorously checking all user-supplied data against a predefined set of rules to ensure it conforms to expected formats, types, and lengths, and does not contain malicious characters or patterns. By sanitizing or rejecting input that includes script tags, event handlers, or other potentially dangerous constructs at the earliest possible point (e.g., on the server-side), input validation acts as a crucial first line of defense against XSS and other injection attacks.

About these practice questions

This CEH question is part of Courseiva's 870-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.