Skip to content

Commit 49c2e06

Browse files
authored
Merge pull request #56 from wasabina67/fix/prototype-pollution-removeAttributeNS-complete
Fix prototype pollution vulnerability in removeAttributeNS
2 parents 4490b40 + 9666461 commit 49c2e06

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

dom-element.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ DOMElement.prototype.getAttributeNS =
128128

129129
DOMElement.prototype.removeAttributeNS =
130130
function _Element_removeAttributeNS(namespace, name) {
131-
// Safely access and delete the attribute
131+
// Prevent prototype pollution by checking if namespace is a direct property
132+
if (!Object.prototype.hasOwnProperty.call(this._attributes, namespace)) {
133+
return;
134+
}
132135
var attributes = this._attributes[namespace];
133136
if (attributes && Object.prototype.hasOwnProperty.call(attributes, name)) {
134137
delete attributes[name];

0 commit comments

Comments
 (0)