Express 4.22
Last reviewed Oct 12, 2026
Prompt Details
Prompt Composition
3prompts
- JavaScript ES2026102 lines · 3.1K tokens
- Node.js 24101 lines · 5.3K tokens
- Express 4.2267 lines · 3.3K tokens
Total270 lines · 11.7K tokens
CWE Coverage
- 20
- 22
- 59
- 78
- 79
- 88
- 89
- 95
- 113
- 117
- 208
- 209
- 214
- 250
- 295
- 297
- 307
- 319
- 323
- 330
- 338
- 346
- 347
- 352
- 354
- 362
- 367
- 377
- 384
- 426
- 434
- 444
- 459
- 471
- 488
- 494
- 502
- 524
- 532
- 552
- 601
- 602
- 613
- 614
- 653
- 732
- 770
- 807
- 829
- 838
- 862
- 863
- 908
- 915
- 916
- 918
- 922
- 942
- 943
- 1004
- 1321
- 1333
- 1336
Prompt Preview
Apply the Node.js 24 and JavaScript ES2026 prompts first. These rules cover Express 4.22 proxy trust, routing, parsers, middleware order, sessions, browser boundaries, files, errors, and production deployment.
Proxy and request trust
- Keep the
trust proxydefaultfalseunless deployment topology is proven; avoid booleantrueand numeric hop counts when clients can reach the app through shorter paths, and prefer exact proxy subnets or a reviewed function. - Write IPv4
trust proxysubnets in plain notation such as10.0.0.0/8. Never use an IPv4-mapped IPv6 subnet with a short prefix such as::ffff:10.0.0.0/8, or an IPv6 block with zero leading bits such as::/1, becauseproxy-addrcan compile them to a different block, up to every IPv4 client; if mapped notation is required, write the full prefix such as::ffff:10.0.0.0/104. Test that a direct client'sX-Forwarded-Fordoes not changereq.iporreq.ips. - Do not trust
X-Forwarded-*values from direct clients or proxies outside the configured boundary. - Validate
req.hostnameagainst exact production hosts before using it for links, tenant routing, or security decisions. - Treat path parameters, query values, body properties, headers, cookies, and files as separate untrusted namespaces.
- Reject ambiguous duplicate security-sensitive values instead of relying on parser-dependent selection.
Parsers and request limits
- Install only the body parsers each route needs and set valid, finite byte limits. Check any configured or computed
limitat startup withbytes.parse()and refuse to start