Skip to main content

Insecure session management - Change Password

Description

After a password change the session remains open.

Impact

Keep the control of an account whose session has been compromised.

Recommendation

The open session must be closed after a password change process.

Threat

Unauthorized user from the Internet with access to a users session.

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: L
  • User interaction: N
  • Scope: U
  • Confidentiality: L
  • Integrity: N
  • Availability: N

Temporal

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

Result

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

Code Examples

Compliant code

The server deletes all existing sessions after a password change

app.get('/login',(req,res) => {
const userCredentials = req.body.userCredentials;
const sessionToken = req.body.token;
if(isValidLogin(userCredentials)){
req.session.destroy();
sendUserNotice(userCredentials.userId);
changeUserPassword(userCredentials);
res.redirect('/profile');
}
});

Non compliant code

After a password change, the application does not delete existing user sessions

app.get('/passwordChange',(req,res) => {
const userCredentials = req.body.userCredentials;
const sessionToken = req.body.token;
if(isValidPassword(userCredentials)){
//Code to handle password change without deleting existing session
changeUserPassword(userCredentials);
res.redirect('/userProfile');
}
});

Requirements