Skip to content

Commit

Permalink
chore: added test for prototype pollution protection
Browse files Browse the repository at this point in the history
  • Loading branch information
cure53 committed Aug 27, 2020
1 parent 082b204 commit db7ec8b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/test-suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -1464,4 +1464,16 @@ module.exports = function (DOMPurify, window, tests, xssTests) {
]);
}
);
QUnit.test(
'Test protection from prototype pollution attacks',
function (assert) {

const obj = JSON.parse('{"ALLOWED_ATTR":["onerror","src"]}');
for (let [k, v] of Object.entries(obj)) {
Object.prototype[k] = v;
}
var clean = DOMPurify.sanitize('<img src=x onerror=alert(1)>');
assert.equal(clean, '<img src="x">');
}
);
};

0 comments on commit db7ec8b

Please sign in to comment.