Skip to content

Commit 654d925

Browse files
committed
🔒️ fix CVE-2019-11358
1 parent 8bdec18 commit 654d925

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/core.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,9 @@ jQuery.extend = jQuery.fn.extend = function() {
576576
for ( var name in options ) {
577577
var src = target[ name ], copy = options[ name ];
578578

579+
// Prevent Object.prototype pollution
579580
// Prevent never-ending loop
580-
if ( target === copy )
581+
if ( name === "__proto__" || target === copy )
581582
continue;
582583

583584
// Recurse if we're merging object values

test/unit/core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,13 @@ test("text(String)", function() {
14161416
equals( j[2].nodeType, 8, "Check node,textnode,comment with text()" );
14171417
});
14181418

1419+
test( "jQuery.extend( true, ... ) Object.prototype pollution", function( assert ) {
1420+
expect( 1 );
1421+
1422+
jQuery.extend( true, {}, JSON.parse( "{\"__proto__\": {\"devMode\": true}}" ) );
1423+
ok( !( "devMode" in {} ), "Object.prototype not polluted" );
1424+
} );
1425+
14191426
test("$.each(Object,Function)", function() {
14201427
expect(12);
14211428
$.each( [0,1,2], function(i, n){

0 commit comments

Comments
 (0)