Skip to content

Commit 9666461

Browse files
committed
Fix prototype pollution vulnerability in removeAttributeNS
1 parent 4490b40 commit 9666461

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)