CCSP Cloud Application Security Practice Question
A developer is tasked with securely storing a session token in a browser-based web application. Which storage mechanism is most secure?
⚠ Common exam trap
ISC2 often tests the misconception that localStorage or sessionStorage is secure because they are 'client-side only,' but the trap is that both are fully accessible via JavaScript and thus vulnerable to XSS, whereas HTTP-only cookies are the only option that prevents script-level access.
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
✓
HTTP-only cookies with Secure and SameSite flags
HTTP-only cookies with Secure and SameSite flags are the most secure storage mechanism for session tokens because they prevent client-side script access (mitigating XSS-based token theft), ensure transmission only over HTTPS (mitigating network eavesdropping), and restrict cross-origin request inclusion (mitigating CSRF). This combination aligns with OWASP best practices for session management, as the token is never exposed to JavaScript or sent over unencrypted channels.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
HTTP-only cookies with Secure and SameSite flags
Why this is correct
HTTP-only cookies are inaccessible to JavaScript, so cross-site scripting cannot read the token, while Secure restricts transmission to HTTPS and SameSite blocks cross-site request forgery. This satisfies secure browser storage, unlike localStorage, which script can freely exfiltrate.
- ✗
sessionStorage
Why it's wrong here
sessionStorage is still readable by any JavaScript on the origin, so XSS exfiltrates the token; it merely clears on tab close. It suits transient per-tab form drafts or wizard state, not credentials needing HttpOnly and Secure cookie protections.
- ✗
URL query parameters
Why it's wrong here
URL query parameters expose the token in browser history, server access logs, and Referer headers sent to third parties. They suit shareable, non-sensitive state such as search filters or pagination, which is why they appear in bookmarkable links, but never credentials.
- ✗
localStorage
Why it's wrong here
localStorage persists until explicitly cleared and is readable by any JavaScript on the origin, so a single XSS flaw leaks the token indefinitely. It suits non-sensitive client preferences like theme or language, not session credentials requiring expiry and isolation.
Go deeper
Related to this question
About these practice questions
This CCSP question is part of Courseiva's 934-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 →
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.