Skip to content

Commit a4cc7c0

Browse files
committedFeb 28, 2021
Add a test to confirm we are not vulnerable to CVE-2021-23337 (#2911)
1 parent 745e9b7 commit a4cc7c0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎test/utility.js

+15
Original file line numberDiff line numberDiff line change
@@ -465,4 +465,19 @@
465465
assert.strictEqual(template(), '<<\nx\n>>');
466466
});
467467

468+
QUnit.test('#2911 - _.template must not trigger CVE-2021-23337.', function(assert) {
469+
QUnit.holyProperty = 'holy';
470+
var invalidVariableNames = [
471+
'){delete QUnit.holyProperty}; with(obj',
472+
'(x = QUnit.holyProperty = "evil"), obj',
473+
'document.write("got you!")'
474+
];
475+
_.each(invalidVariableNames, function(name) {
476+
assert.throws(function() { _.template('', { variable: name })(); });
477+
});
478+
var holy = QUnit.holyProperty;
479+
delete QUnit.holyProperty;
480+
assert.strictEqual(holy, 'holy');
481+
});
482+
468483
}());

0 commit comments

Comments
 (0)
Please sign in to comment.