Skip to main content

Insecure session management

Description

The session token does not expire when the user terminates the session and can be used to post requests afterwards.

Impact

  • Access the session of a previously authenticated user.
  • Make enquiries to obtain confidential information.
  • Create accompaniments without prior authorization from a user.
  • Obtain business information with valid token.

Recommendation

Ensure the expiration of the session token after the user logs out.

Threat

Anonymous attacker from the Internet with access to a session token.

Expected Remediation Time

⌚ 60 minutes.

Score

Default score using CVSS 3.1. It may change depending on the context of the vulnerability.

Base

  • Attack vector: N
  • Attack complexity: H
  • Privileges required: N
  • User interaction: R
  • Scope: U
  • Confidentiality: L
  • Integrity: L
  • Availability: N

Temporal

  • Exploit code madurity: X
  • Remediation level: X
  • Report confidence: X

Result

  • Vector string: CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N/E:X/RL:X/RC:X
  • Score:
    • Base: 4.2
    • Temporal: 4.2
  • Severity:
    • Base: Medium
    • Temporal: Medium

Code Examples

Compliant code

After logging out of the application, the session token of the user should be deleted too

function generateAccessToken(username){
return jwt.sign(username, process.env.TOKEN_SECRET, { expiresIn: '1800s'});
}

function userLogout(userId, sessionToken){
logout(userId);
deleteToken(sessionToken);
}

Non compliant code

The log out functionality of the application does not delete the session tokens

function generateAccessToken(username){
return jwt.sign(username, process.env.TOKEN_SECRET, {expiresIn: '3600s'});
}

function userLogout(userId){
logout(userId);
}

Requirements