Skip to content

Commit 2105dd1

Browse files
1 parent 5a4afd3 commit 2105dd1

1 file changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-46wh-pxpv-q5gq",
4+
"modified": "2026-03-06T18:36:56Z",
5+
"published": "2026-03-06T18:36:56Z",
6+
"aliases": [
7+
"CVE-2026-30827"
8+
],
9+
"summary": "express-rate-limit: IPv4-mapped IPv6 addresses bypass per-client rate limiting on servers with dual-stack network",
10+
"details": "## Summary\n\nThe default `keyGenerator` in express-rate-limit applies IPv6 subnet masking (`/56` by default) to all addresses that `net.isIPv6()` returns true for. This includes IPv4-mapped IPv6 addresses (`::ffff:x.x.x.x`), which Node.js returns as `request.ip` on dual-stack servers.\n\nBecause the first 80 bits of all IPv4-mapped addresses are zero, a `/56` (or any `/32` to `/80`) subnet mask produces the same network key (`::/56`) for **every** IPv4 client. This collapses all IPv4 traffic into a single rate-limit bucket: one client exhausting the limit causes HTTP 429 for all other IPv4 clients.\n\n## Details\n\n### Root Cause\n\nIn `source/ip-key-generator.ts`:\n\n```typescript\nexport function ipKeyGenerator(ip: string, ipv6Subnet: number | false = 56) {\n if (ipv6Subnet && isIPv6(ip)) {\n return `${new Address6(`${ip}/${ipv6Subnet}`).startAddress().correctForm()}/${ipv6Subnet}`\n }\n return ip\n}\n```\n\n`net.isIPv6('::ffff:192.168.1.1')` returns `true`, so IPv4-mapped addresses enter the subnet masking path. With a `/56` prefix, the start address for any `::ffff:x.x.x.x` is `::`, producing the key `::/56`.\n\n### Proof of Concept\n\n```javascript\nconst { isIPv6 } = require('net');\nconst { Address6 } = require('ip-address');\n\nfunction ipKeyGenerator(ip, ipv6Subnet = 56) {\n if (ipv6Subnet && isIPv6(ip)) {\n return `${new Address6(`${ip}/${ipv6Subnet}`).startAddress().correctForm()}/${ipv6Subnet}`;\n }\n return ip;\n}\n\nconsole.log(ipKeyGenerator('::ffff:192.168.1.1', 56)); // ::/56\nconsole.log(ipKeyGenerator('::ffff:10.0.0.1', 56)); // ::/56\nconsole.log(ipKeyGenerator('::ffff:8.8.8.8', 56)); // ::/56\n// ALL produce '::/56' — same bucket\n```\n\n### End-to-End Validation\n\nOn a dual-stack Express server (`app.listen(port, '::')`), tested with Express 5.2.1:\n- `request.ip` for IPv4 clients is `::ffff:127.0.0.1`\n- Rate limit key resolves to `::/56`\n- After `limit` requests from any IPv4 client, all other IPv4 clients receive 429\n\n### When This Occurs\n\n- Node.js dual-stack servers (default on Linux when listening on `::`)\n- Any environment where `request.ip` contains IPv4-mapped IPv6 addresses\n- Only affects the default `keyGenerator` (custom key generators are not affected)\n\n## Impact\n\n- **Denial of Service**: A single client can block all IPv4 traffic by exhausting the shared rate limit\n- **Affects default configuration**: No special options needed to trigger this\n\n## Affected Versions\n\nAll versions of express-rate-limit between v8.0.0 and v8.2.1.\n\n## Fix\n\nThis issue was fixed in commit 14e53888cdfd1b9798faf5b634c4206409e27fc4. This fix has been included in release v8.3.0, and backported to all affected minor versions in the form of releases v8.2.2, v8.1.1, and v8.0.2.",
11+
"severity": [
12+
{
13+
"type": "CVSS_V3",
14+
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "npm",
21+
"name": "express-rate-limit"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "8.2.0"
29+
},
30+
{
31+
"fixed": "8.2.2"
32+
}
33+
]
34+
}
35+
]
36+
},
37+
{
38+
"package": {
39+
"ecosystem": "npm",
40+
"name": "express-rate-limit"
41+
},
42+
"ranges": [
43+
{
44+
"type": "ECOSYSTEM",
45+
"events": [
46+
{
47+
"introduced": "8.1.0"
48+
},
49+
{
50+
"fixed": "8.1.1"
51+
}
52+
]
53+
}
54+
],
55+
"versions": [
56+
"8.1.0"
57+
]
58+
},
59+
{
60+
"package": {
61+
"ecosystem": "npm",
62+
"name": "express-rate-limit"
63+
},
64+
"ranges": [
65+
{
66+
"type": "ECOSYSTEM",
67+
"events": [
68+
{
69+
"introduced": "8.0.0"
70+
},
71+
{
72+
"fixed": "8.0.2"
73+
}
74+
]
75+
}
76+
]
77+
}
78+
],
79+
"references": [
80+
{
81+
"type": "WEB",
82+
"url": "https://github.com/express-rate-limit/express-rate-limit/security/advisories/GHSA-46wh-pxpv-q5gq"
83+
},
84+
{
85+
"type": "WEB",
86+
"url": "https://github.com/express-rate-limit/express-rate-limit/commit/14e53888cdfd1b9798faf5b634c4206409e27fc4"
87+
},
88+
{
89+
"type": "PACKAGE",
90+
"url": "https://github.com/express-rate-limit/express-rate-limit"
91+
}
92+
],
93+
"database_specific": {
94+
"cwe_ids": [
95+
"CWE-770"
96+
],
97+
"severity": "HIGH",
98+
"github_reviewed": true,
99+
"github_reviewed_at": "2026-03-06T18:36:56Z",
100+
"nvd_published_at": null
101+
}
102+
}

0 commit comments

Comments
 (0)