Express 5
Last reviewed Oct 19, 2026
Prompt Details
Prompt Composition
3prompts
- JavaScript ES2026102 lines · 3.1K tokens
- Node.js 24101 lines · 5.3K tokens
- Express 564 lines · 3.3K tokens
Total267 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
- 639
- 653
- 732
- 770
- 807
- 829
- 838
- 862
- 863
- 908
- 915
- 916
- 918
- 922
- 942
- 943
- 1004
- 1321
- 1333
Prompt Preview
Apply the Node.js 24 prompt first. These rules cover Express 5 and the named middleware when the application uses it.
Routing and request boundaries
- Mount authentication and authorization with
app.use()orrouter.use()before protected handlers and file middleware. End denied requests;next('route')andnext('router')select other handlers and do not deny access. Protect fallback routes and every mount of a router. - Authorize the authenticated principal against each object selected by
req.params,req.query, orreq.body; do not take tenant scope or ownership from submitted fields. For injection-safe queries, pass validated scalar values to the database layer's bindings, never entire Express request objects as filters or updates. - Validate
req.params,req.query, andreq.bodyseparately. Reject unexpected arrays, objects, duplicate security fields, and unknown writable fields. Snapshot validated query values into a separate request-local object:req.queryis a getter, so mutating one returned object does not sanitize later reads. Treat an unparsedreq.bodyas absent, not as a validated empty object. - Use Express 5 path syntax for security middleware:
/*splatexcludes/, while/{*splat}includes it; wildcard captures are arrays. Check protected paths under the router's case sensitivity, trailing-slash behavior, and nested mounts. Do not replace a failed route pattern with a broader unguarded fallback. - In login handlers, complete password storage verification through the baseline's password-hashing APIs before establishing a session.