Courseiva
mediumMultiple SelectObjective-mapped

CAS-004 Session hijacking prevention Practice Question

A security analyst is reviewing a web application's authentication mechanism. Which of the following are best practices to prevent session hijacking? (Select TWO.)

⚠ Common exam trap

The CAS-004 exam often tests the misconception that short session timeouts (like 5 minutes) are a primary defense against session hijacking, when in fact they are a secondary mitigation that can harm usability, while the core technical controls are session ID regeneration and cookie security flags.

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

Regenerate session ID upon successful login

Regenerating the session ID upon successful login (option A) is a critical defense against session fixation attacks, where an attacker forces a known session ID on a user before authentication. By issuing a new, server-generated session ID after login, the application ensures that any pre-authentication session ID controlled by an attacker becomes invalid. This practice is recommended by OWASP and aligns with RFC 6265 session management guidelines.

Answer analysis

Option-by-option breakdown

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

  • Set the session timeout to 5 minutes

    Why it's wrong here

    Short timeouts reduce risk but do not prevent hijacking; they are a mitigation, not a prevention.

  • Use the same session ID before and after authentication

    Why it's wrong here

    Using the same session ID allows session fixation attacks.

  • Store session tokens in localStorage

    Why it's wrong here

    localStorage is accessible by JavaScript and vulnerable to XSS; cookies with HttpOnly flag are more secure.

Option-by-option analysis

Why each answer is right or wrong

Understanding why wrong answers are wrong — and when they would be correct — is what separates a 750 score from a 900. The CAS-005 exam frequently reuses these exact scenarios with slightly different constraints.

Regenerate session ID upon successful loginCorrect answer
Set the session timeout to 5 minutesWrong answer — click to see why

Why this is wrong here

Short timeouts reduce risk but do not prevent hijacking; they are a mitigation, not a prevention.

Use the same session ID before and after authenticationWrong answer — click to see why

Why this is wrong here

Using the same session ID allows session fixation attacks.

Store session tokens in localStorageWrong answer — click to see why

Why this is wrong here

localStorage is accessible by JavaScript and vulnerable to XSS; cookies with HttpOnly flag are more secure.

Analysis generated from the official CAS-005blueprint and verified against question context. The “when correct” sections are what AI assistants cite when candidates ask “what’s the difference between these options?”

About these practice questions

Courseiva writes every CAS-005 question from scratch — 968 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 →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This CAS-005 practice question is part of Courseiva's free CompTIA 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 CAS-005 exam.