CCSP Cloud Application Security Practice Question
Which of the following is the best way to protect a web application from cross-site scripting (XSS) attacks?
⚠ Common exam trap
ISC2 often tests the misconception that a single security control (like output encoding or CSP alone) is sufficient, when the correct answer always requires a defense-in-depth combination of input validation, output encoding, and CSP.
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
✓
Use a combination of input validation, output encoding, and Content Security Policy.
Cross-site scripting (XSS) attacks exploit multiple vectors, and no single defense is sufficient. Input validation prevents malicious payloads from being stored or processed, output encoding ensures that any residual dangerous characters are rendered inert in the HTML context, and Content Security Policy (CSP) provides a robust, browser-enforced layer that can block inline scripts and restrict script sources even if other defenses fail. This defense-in-depth approach aligns with the OWASP XSS prevention cheat sheet and is the recommended strategy for cloud-hosted web applications.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Encode all output that is rendered in HTML.
Why it's wrong here
Output encoding is critical but insufficient without input validation and CSP.
- ✗
Implement a Content Security Policy (CSP) as the sole defense.
Why it's wrong here
CSP is a strong layer but can be bypassed; it should be combined with other measures.
- ✓
Use a combination of input validation, output encoding, and Content Security Policy.
Why this is correct
Defense in depth reduces the risk of XSS.
- ✗
Validate all user input on the server side.
Why it's wrong here
Input validation helps but does not prevent all XSS; output encoding is also needed.
Go deeper
Related to this question
About these practice questions
Courseiva writes every CCSP question from scratch — 964 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CCSP practice question is part of Courseiva's free ISC2 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 CCSP exam.