EJS 7

Last reviewed Oct 26, 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 742 lines · 1.6K tokens
Total245 lines · 10K 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. Use these rules for EJS 7 template rendering on Node.js, and the browser rules when shipping its client bundle.

Template and rendering authority

  • Pass only application-owned template text to ejs.compile() and ejs.render(), and only application-owned files to ejs.renderFile(). EJS evaluates JavaScript in templates; sanitizing a user-authored template as HTML does not make it safe to execute.
  • Select views from an explicit set of names authorized for the current user and tenant. Do not use a request path directly as a template filename, renderFile() argument, or include() target.
  • Build a small view model from approved fields before rendering. Do not pass req.query, req.body, request or session objects, service containers, or callable helpers through to templates; nested values and getters remain live after EJS copies locals.
  • Pass compiler and lookup settings in a separate, application-owned options object to ejs.render(template, data, options) or ejs.renderFile(path, data, options, callback). Keep escape, delimiters, filename, root, views, includer, context, and cache settings out of user-controlled data and configuration.
  • For Express, register app.engine('ejs', (path, data, callback) => ejs.renderFile(path, data, trustedOptions, callback)) when the app needs EJS options. Carry Express's trusted views and view cache settings into that adapter deliberately. EJS 7 no longer reads EJS options from render locals or app.set('view options'); its default renderFile() integration still reads