Skip to content

Commit 8365748

Browse files
committed
🔒️ fix CVE-2019-11358
1 parent 9f2e4d3 commit 8365748

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
@@ -156,8 +156,9 @@ jQuery.extend = jQuery.fn.extend = function() {
156156
src = target[ name ];
157157
copy = options[ name ];
158158

159+
// Prevent Object.prototype pollution
159160
// Prevent never-ending loop
160-
if ( target === copy ) {
161+
if ( name === "__proto__" || target === copy ) {
161162
continue;
162163
}
163164

test/unit/core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,13 @@ QUnit.test( "jQuery.extend(true,{},{a:[], o:{}}); deep copy with array, followed
12281228
assert.ok( !jQuery.isArray( result.object ), "result.object wasn't paved with an empty array" );
12291229
} );
12301230

1231+
QUnit.test( "jQuery.extend( true, ... ) Object.prototype pollution", function( assert ) {
1232+
assert.expect( 1 );
1233+
1234+
jQuery.extend( true, {}, JSON.parse( "{\"__proto__\": {\"devMode\": true}}" ) );
1235+
assert.ok( !( "devMode" in {} ), "Object.prototype not polluted" );
1236+
} );
1237+
12311238
QUnit.test( "jQuery.each(Object,Function)", function( assert ) {
12321239
assert.expect( 23 );
12331240

0 commit comments

Comments
 (0)