Information Security Basics

If a web application keeps using the same session ID before and after login, an attacker may get the user to use a session ID the attacker prepared in advance and then, after the user logs in, impersonate the user with that ID. What is the most appropriate countermeasure against this attack?

  1. AMake session IDs sequential numbers per user so they are easier to manage
  2. BIssue a new session ID when login succeeds and invalidate the previous ID
  3. CPass the session ID inside the URL
Show answer and explanation

Answer: B. Issue a new session ID when login succeeds and invalidate the previous ID

This attack is called session fixation. A web application recognizes a logged-in user by a session ID passed in a cookie or similar. If an attacker can get the user to use a session ID the attacker knows before login, and that ID continues to be used after login, the attacker can access the site as the user with the same ID. The countermeasure is to issue a new, unpredictable session ID at the moment login succeeds and invalidate the old one. The ID the attacker knew before login then becomes useless. Attacks that impersonate users by stealing or guessing session IDs in general are called session hijacking, and they are countered by combining measures such as making IDs sufficiently long random values, sending them only over HTTPS (the cookie's Secure attribute), and not putting them in URLs (where they easily leak through the Referer header or history). Sequential IDs are easy to guess and dangerous.

  • A. Sequential IDs are easy to guess, increasing the risk of impersonating other users.
  • B. Correct. Renewing the ID at login makes the ID the attacker knew in advance unusable.
  • C. Session IDs in URLs easily leak through the Referer header, browsing history, shared links and so on.
Practice this topic Back to topic

Related calculators

Books on Information Security Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Information Security Basics questions

  1. Which statement correctly describes a DDoS attack?
  2. Which statement correctly describes a zero-day attack?
  3. Which combination correctly describes CVE and CVSS, used in vulnerability management?
  4. On an employee's PC, file extensions start changing one after another and a screen demanding a ransom appears. What is the most appropriate first action for this employee?
  5. A company's business system received a flood of requests and stopped responding, so users could not use it when they needed to. Which of the three elements of information security (confidentiality, integrity, availability) was mainly compromised?