Skip to content

Sync 5.0 with the 4.4.0 release and flip security defaults - #286

Merged
UlisesGascon merged 9 commits into
5.0from
feat/5.0-options-secure-defaults
Nov 17, 2026
Merged

UlisesGascon merged 9 commits into
5.0from
feat/5.0-options-secure-defaults

Conversation

@UlisesGascon

Copy link
Copy Markdown
Member

Brings the 5.0 branch in line with the latest 4.x release (#285) and ships the breaking security-defaults change that 5.0 exists for. The two lines diverged a while ago, so 5.0 was missing the recent 4.x work.

What this does

  • chore(deps): bump handlebars 4.7.8 to 4.7.10 (as in #283)
  • feat: port the compileOptions instance option (#268)
  • feat: port the runtimeOptions instance option (#284)
  • feat!: flip allowProtoMethodsByDefault and allowProtoPropertiesByDefault to false (handlebars' safe defaults)
  • Backfill HISTORY.md with the 4.2.1 / 4.3.0 / 4.3.1 / 4.4.0 entries and add a 5.0.0 entry
  • README: new Security, Compile options, and Runtime options sections

Breaking change

Inherited (prototype) members of the data are no longer readable from templates by default. Apps that need prototype access opt back in per instance:

const hbs = require('hbs')

const instance = hbs.create(null, {
  runtimeOptions: {
    allowProtoMethodsByDefault: true,
    allowProtoPropertiesByDefault: true,
  },
})

app.engine('hbs', instance.__express)

Notes

  • package.json version is intentionally left at 4.2.0; the 5.0.0 bump belongs to the release step.
  • Tests run on vitest, 45 passing. Includes a regression test for the GHSA-3c55-w9jx-p5jr async-escaping DoS, which is a non-gap on 5.0: handlebars 4.7.10 fixes the root cause, and the promise-based pipeline already turns substitution throws into handled render errors.

@UlisesGascon
UlisesGascon marked this pull request as ready for review October 15, 2026 10:15
@UlisesGascon
UlisesGascon requested a review from mfdebian October 16, 2026 17:13

@mfdebian mfdebian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nitpicking comments tbh, but otherwise it LGTM!

This PR does need rebasing now though, so it can land safely!

Thank you @UlisesGascon!

Comment thread lib/hbs.js Resolved
Comment thread README.md Resolved
Comment thread HISTORY.md Resolved
allowProtoMethodsByDefault and allowProtoPropertiesByDefault now default
to false (handlebars' safe defaults); opt back in via the runtimeOptions
instance option. Includes the 5.0.0 HISTORY entry and the GHSA-3c55
async-escaping regression test.

BREAKING CHANGE: inherited (prototype) members of the data are no longer
readable from templates by default. Set allowProtoMethodsByDefault
and/or allowProtoPropertiesByDefault to true via runtimeOptions to
restore the previous behavior.
Build the runtime options object on a null prototype and stop setting
allowProtoMethodsByDefault / allowProtoPropertiesByDefault explicitly.
Blocked lookups now log handlebars' warning, and options can no longer
be inherited from Object.prototype.
@UlisesGascon
UlisesGascon force-pushed the feat/5.0-options-secure-defaults branch from acce2c3 to 24e3bb5 Compare November 13, 2026 14:11
Comment thread test/runtime_options.test.js Resolved
@UlisesGascon
UlisesGascon merged commit 08c4ca0 into 5.0 Nov 17, 2026
40 checks passed
@UlisesGascon
UlisesGascon deleted the feat/5.0-options-secure-defaults branch November 17, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants