Skip to content

Commit ab024c1

Browse files
committed
🔒️ fix CVE-2019-11358
1 parent eb69988 commit ab024c1

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

build/post-compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
var print = require( "sys" ).print,
3+
var print = console.log,
44
fs = require( "fs" ),
55
src = fs.readFileSync( process.argv[2], "utf8" ),
66
version = fs.readFileSync( "version.txt", "utf8" ),

jquery.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright 2011, The Dojo Foundation
1212
* Released under the MIT, BSD, and GPL Licenses.
1313
*
14-
* Date: Wed Feb 12 09:58:38 2014 -0800
14+
* Date: Mon Dec 11 15:34:47 2023 -0600
1515
*/
1616
(function( window, undefined ) {
1717

@@ -38,7 +38,8 @@ var jQuery = function( selector, context ) {
3838

3939
// A simple way to check for HTML strings or ID strings
4040
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
41-
quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
41+
// Strict HTML recognition (#11290: must start with <)
42+
quickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/, // jslint ignore:line
4243

4344
// Check if a string has a non-whitespace character in it
4445
rnotwhite = /\S/,
@@ -357,8 +358,9 @@ jQuery.extend = jQuery.fn.extend = function() {
357358
src = target[ name ];
358359
copy = options[ name ];
359360

361+
// Prevent Object.prototype pollution
360362
// Prevent never-ending loop
361-
if ( target === copy ) {
363+
if ( name === "__proto__" || target === copy ) {
362364
continue;
363365
}
364366

src/core.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,9 @@ jQuery.extend = jQuery.fn.extend = function() {
337337
src = target[ name ];
338338
copy = options[ name ];
339339

340+
// Prevent Object.prototype pollution
340341
// Prevent never-ending loop
341-
if ( target === copy ) {
342+
if ( name === "__proto__" || target === copy ) {
342343
continue;
343344
}
344345

test/unit/core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,13 @@ test("jQuery.extend(Object, Object)", function() {
854854
same( options2, options2Copy, "Check if not modified: options2 must not be modified" );
855855
});
856856

857+
QUnit.test( "jQuery.extend( true, ... ) Object.prototype pollution", function( assert ) {
858+
assert.expect( 1 );
859+
860+
jQuery.extend( true, {}, JSON.parse( "{\"__proto__\": {\"devMode\": true}}" ) );
861+
assert.ok( !( "devMode" in {} ), "Object.prototype not polluted" );
862+
} );
863+
857864
test("jQuery.each(Object,Function)", function() {
858865
expect(14);
859866
jQuery.each( [0,1,2], function(i, n){

0 commit comments

Comments
 (0)