EJS 6

Last reviewed Sep 19, 2026

Export as PDF

Prompt Details

Prompt Composition

3prompts
  1. JavaScript ES2026102 lines · 3.1K tokens
  2. Node.js 24101 lines · 5.3K tokens
  3. EJS 651 lines · 1.9K tokens
Total254 lines · 10.3K tokens

CWE Coverage

  • 15
  • 20
  • 22
  • 59
  • 78
  • 79
  • 88
  • 89
  • 95
  • 113
  • 117
  • 201
  • 208
  • 209
  • 214
  • 250
  • 295
  • 297
  • 319
  • 323
  • 330
  • 338
  • 346
  • 347
  • 352
  • 354
  • 362
  • 367
  • 377
  • 426
  • 444
  • 459
  • 471
  • 488
  • 494
  • 502
  • 524
  • 532
  • 602
  • 653
  • 732
  • 770
  • 807
  • 829
  • 838
  • 862
  • 863
  • 908
  • 916
  • 918
  • 922
  • 942
  • 943
  • 1004
  • 1321
  • 1333

Prompt Preview

Apply the Node.js 24 prompt first. These rules target EJS 6 on Node.js 24 and were checked against 6.0.1; apply the browser-delivery rule when shipping EJS to clients.

Template and option authority

  • Treat templates passed to ejs.compile() or ejs.render() and files loaded by ejs.renderFile(), including loader-produced partials, as application code. Never compile user-authored content or recompile rendered output, even after HTML sanitization.
  • Supply a separate, developer-owned options object to ejs.render(template, viewModel, options) and ejs.renderFile(filename, viewModel, options[, callback]). The two-argument render() form and renderFile() without explicit options promote selected data properties into engine options.
  • Construct locals from explicitly selected fields; never pass req.query, req.body, or an unrestricted spread of input directly to a rendering API. Keep compiler settings, callbacks, and delimiter choices outside the user-controlled view model.
  • Keep Express settings, settings['view options'], and option-bearing app.locals, res.locals, and render locals server-owned. EJS reads view paths and caching from settings, copies view options, and then lets recognized top-level locals override them. Use an app.engine() adapter that calls ejs.renderFile(path, data, trustedOptions, callback) when options must be independent of these locals.

Locals and execution context

  • Keep unsafePrototypeLocals: false, the v6 default. EJS copies own enumerable locals to an object without a prototype; project required class properties