Files
handlebars.js/spec/security.js
T
Nils Knappmeier d3e8e46095 fix: disallow the use of constructors in templates
This closes a major security leak that allows execution of arbitrary
code in a NodeJS environment by creating a special Handlebars template.
2019-01-30 22:21:44 +01:00

23 lines
752 B
JavaScript

describe('security issues', function() {
it('should not allow constructors to be accessed', function() {
shouldCompileTo('{{#with this as |obj|}}{{obj.constructor.name}}{{/with}}', {}, '');
});
it('should allow the "constructor" property to be accessed if it is enumerable', function() {
shouldCompileTo('{{constructor.name}}', {'constructor': {
'name': 'here we go'
}}, 'here we go');
});
it('should allow prototype properties that are not constructors', function() {
class TestClass {
get abc() {
return 'xyz';
}
}
shouldCompileTo('{{#with this as |obj|}}{{obj.abc}}{{/with}}',
new TestClass(), 'xyz');
});
});