CVE-2024-43796: XSS Vulnerability in Express

express Updated 02 Oct 2025

Summary

10/09/2024
Yes i
Low
5.0

CVE-2024-43796: express vulnerable to XSS via response.redirect(). Affects express across 2 version ranges.

< 4.20.0 >= 5.0.0-alpha.1, < 5.0.0

Fixed in 4.20.0 or 5.0.0, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2024-43796 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

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 Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Express is a popular web application framework for Node.js that simplifies the process of building web applications and APIs. It provides a robust set of features and middleware to handle various aspects of web development. However, versions of Express prior to 4.20.0 are vulnerable to a cross-site scripting (XSS) attack when untrusted user input is passed to the response.redirect() function.

Vulnerability Detail

The vulnerability arises when untrusted user input, even after being sanitized, is used as an argument for response.redirect(). This can lead to the execution of untrusted code. Successful exploitation of this vulnerability requires several conditions to be met: 1) The attacker must control the input to response.redirect(), 2) Express must not redirect before the template appears, and 3) The browser must not complete redirection before the user clicks on the link in the template. The impact of this vulnerability can range from unauthorized code execution to the theft of sensitive user information.

How To Fix

Latest published version: 5.3.0 as of 22 Oct 2026

npm install express@5.3.0

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 4.20.0 4.20.0
    npm install express@4.20.0
  • >= 5.0.0-alpha.1, < 5.0.0 5.0.0
    npm install express@5.0.0

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

To mitigate the vulnerability without upgrading, it is important to validate any user input against an allowlist. This can be done by implementing proper input validation and sanitization techniques. Here is an example of how to validate user input using the express-validator library:

const { body, validationResult } = require('express-validator');

app.post('/login', [
  body('username').isAlphanumeric(),
  body('password').isLength({ min: 8 })
], (req, res) => {
  const errors = validationResult(req);
  if (!errors.isEmpty()) {
    return res.status(400).json({ errors: errors.array() });
  }

  // Proceed with login logic
});

Conclusion

The XSS vulnerability in Express versions prior to 4.20.0 can allow for the execution of untrusted code when untrusted user input is passed to response.redirect(). It is crucial to upgrade to the patched version or implement proper input validation and sanitization techniques to mitigate the risk of exploitation.

See every vulnerability recorded for express →

Share this vulnerability

FAQ

The vulnerability allows for the execution of untrusted code, which can lead to various consequences such as unauthorized code execution or the theft of sensitive user information.

Versions of Express prior to 4.20.0 are affected by this vulnerability.

The vulnerability can be fixed by upgrading to Express version 4.20.0 or higher. Alternatively, you can validate untrusted inputs against an explicit allowlist to ensure their safety.

Yes, if upgrading is not possible, you can implement proper input validation and sanitization techniques to mitigate the vulnerability. Validating user input against an allowlist is recommended.

Related vulnerabilities

Recent vulnerabilities recorded for express.

How To Fix

Latest published version: 5.3.0 as of 22 Oct 2026

npm install express@5.3.0

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 4.20.0 4.20.0
    npm install express@4.20.0
  • >= 5.0.0-alpha.1, < 5.0.0 5.0.0
    npm install express@5.0.0

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. 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