Session Regeneration Vulnerability in PassportJS: CVE-2022-25896

passportjs Updated 02 Oct 2025

Summary

01/07/2022
N/A
No i
Medium
4.8

CVE-2022-25896: This affects the package passport before 0.6.0. When a user logs in or logs out, the session is regenerated instead of being closed. Affects passportjs versions < 7e9b9cf4d7be02428e963fc729496a45baeea608. No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

PassportJS is a popular middleware for Node.js that simplifies the implementation of user authentication in web applications. It supports various authentication strategies and is widely used due to its flexibility and ease of integration. However, prior to version 0.6.0, PassportJS had a vulnerability where user sessions were regenerated upon login or logout instead of being properly closed, potentially leading to session fixation attacks.

Vulnerability Detail

The vulnerability identified as CVE-2022-25896 affects PassportJS versions before 0.6.0. When a user logs in or logs out, the session is regenerated rather than being terminated. This behavior can allow an attacker to exploit the session fixation attack vector, where an attacker can hijack a user's session by forcing the application to reuse an existing session ID. The technical implications of this vulnerability include the potential for unauthorized access to user accounts and sensitive data, as well as the compromise of user trust in the application.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

If you cannot immediately upgrade PassportJS, consider implementing a workaround by manually managing session termination. Ensure that sessions are properly destroyed upon user logout by using the following code snippet:

req.logout(function(err) {
  if (err) { return next(err); }
  req.session.destroy(function(err) {
    if (err) { return next(err); }

res.redirect('/');

// Redirect to home or login page

  });
});

Conclusion

CVE-2022-25896 poses a significant risk to applications using PassportJS versions prior to 0.6.0 due to improper session management. It is crucial for developers to update to the latest version to ensure the security of user sessions and protect sensitive data. Additionally, utilizing tools like Vulert can help monitor and alert for such vulnerabilities in real-time.

See every vulnerability recorded for passportjs →

Share this vulnerability

FAQ

CVE-2022-25896 is a vulnerability in PassportJS that allows session regeneration instead of proper session termination during user login or logout.

You can check if your application is affected by using Vulert's playground at Vulert Scanner, which analyzes your manifest file for vulnerabilities.

The main risk is session fixation, where an attacker can hijack a user's session, leading to unauthorized access to sensitive information.

The CVSS score for CVE-2022-25896 is 4.8, indicating a moderate level of severity.

Yes, you can implement a manual session termination process in your application to mitigate the risk until you can upgrade PassportJS.

Related vulnerabilities

Recent vulnerabilities recorded for passportjs.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback