-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: disallow access to the constructor in templates to prevent RCE
This commit fixes a Remote Code Execution (RCE) reported by npm-security. Access to non-enumerable "constructor"-properties is now prohibited by the compiled template-code, because this the first step on the way to creating and execution arbitrary JavaScript code. The vulnerability affects systems where an attacker is allowed to inject templates into the Handlebars setup. Further details of the attack may be disclosed by npm-security. Closes #1267 Closes #1495
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
describe('security issues', function() { | ||
describe('GH-1495: Prevent Remote Code Execution via constructor', function() { | ||
it('should not allow constructors to be accessed', function() { | ||
shouldCompileTo('{{constructor.name}}', {}, ''); | ||
}); | ||
|
||
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'); | ||
}); | ||
}); | ||
}); |
edc6220
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated security risk correction
edc6220
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MCoop1963 I don't understand your last comment. Could you elaborate?