Skip to content

fix all CVEs in 2.2.4 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 2.2.4-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 51 additions & 41 deletions dist/jquery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jQuery JavaScript Library v2.2.4
* jQuery JavaScript Library v2.2.5-sec
* http://jquery.com/
*
* Includes Sizzle.js
Expand All @@ -9,7 +9,7 @@
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2016-05-20T17:23Z
* Date: 2024-02-21T04:25Z
*/

(function( global, factory ) {
Expand Down Expand Up @@ -65,7 +65,7 @@ var support = {};


var
version = "2.2.4",
version = "2.2.5-sec",

// Define a local copy of jQuery
jQuery = function( selector, context ) {
Expand Down Expand Up @@ -209,8 +209,9 @@ jQuery.extend = jQuery.fn.extend = function() {
src = target[ name ];
copy = options[ name ];

// Prevent Object.prototype pollution
// Prevent never-ending loop
if ( target === copy ) {
if ( name === "__proto__" || target === copy ) {
continue;
}

Expand Down Expand Up @@ -4249,12 +4250,41 @@ var rscriptType = ( /^$|\/(?:java|ecma)script/i );



( function() {
var fragment = document.createDocumentFragment(),
div = fragment.appendChild( document.createElement( "div" ) ),
input = document.createElement( "input" );

// Support: Android 4.0-4.3, Safari<=5.1
// Check state lost if the name is set (#11217)
// Support: Windows Web Apps (WWA)
// `name` and `type` must use .setAttribute for WWA (#14901)
input.setAttribute( "type", "radio" );
input.setAttribute( "checked", "checked" );
input.setAttribute( "name", "t" );

div.appendChild( input );

// Support: Safari<=5.1, Android<4.2
// Older WebKit doesn't clone checked state correctly in fragments
support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;

// Support: IE<=11+
// Make sure textarea (and checkbox) defaultValue is properly cloned
div.innerHTML = "<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;

// Support: IE <=9 only
// IE <=9 replaces <option> tags with their contents when inserted outside of
// the select element.
div.innerHTML = "<option></option>";
support.option = !!div.lastChild;
} )();


// We have to close these tags to support XHTML (#13200)
var wrapMap = {

// Support: IE9
option: [ 1, "<select multiple='multiple'>", "</select>" ],

// XHTML parsers do not magically insert elements in the
// same way that tag soup parsers do. So we cannot shorten
// this by omitting <tbody> or other required elements.
Expand All @@ -4266,12 +4296,14 @@ var wrapMap = {
_default: [ 0, "", "" ]
};

// Support: IE9
wrapMap.optgroup = wrapMap.option;

wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;

// Support: IE <=9 only
if ( !support.option ) {
wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
}


function getAll( context, tag ) {

Expand Down Expand Up @@ -4396,32 +4428,6 @@ function buildFragment( elems, context, scripts, selection, ignored ) {
}


( function() {
var fragment = document.createDocumentFragment(),
div = fragment.appendChild( document.createElement( "div" ) ),
input = document.createElement( "input" );

// Support: Android 4.0-4.3, Safari<=5.1
// Check state lost if the name is set (#11217)
// Support: Windows Web Apps (WWA)
// `name` and `type` must use .setAttribute for WWA (#14901)
input.setAttribute( "type", "radio" );
input.setAttribute( "checked", "checked" );
input.setAttribute( "name", "t" );

div.appendChild( input );

// Support: Safari<=5.1, Android<4.2
// Older WebKit doesn't clone checked state correctly in fragments
support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;

// Support: IE<=11+
// Make sure textarea (and checkbox) defaultValue is properly cloned
div.innerHTML = "<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
} )();


var
rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
Expand Down Expand Up @@ -5121,13 +5127,10 @@ jQuery.fn.extend( {
} );


var
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,

// Support: IE 10-11, Edge 10240+
// In IE/Edge using regex groups here causes severe slowdowns.
// See https://connect.microsoft.com/IE/feedback/details/1736512/
rnoInnerhtml = /<script|<style|<link/i,
var rnoInnerhtml = /<script|<style|<link/i,

// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
Expand Down Expand Up @@ -5322,7 +5325,7 @@ function remove( elem, selector, keepData ) {

jQuery.extend( {
htmlPrefilter: function( html ) {
return html.replace( rxhtmlTag, "<$1></$2>" );
return html;
},

clone: function( elem, dataAndEvents, deepDataAndEvents ) {
Expand Down Expand Up @@ -9194,6 +9197,13 @@ jQuery.ajaxTransport( function( options ) {



// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
jQuery.ajaxPrefilter( function( s ) {
if ( s.crossDomain ) {
s.contents.script = false;
}
} );

// Install script dataType
jQuery.ajaxSetup( {
accepts: {
Expand Down
8 changes: 4 additions & 4 deletions dist/jquery.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jquery.min.map

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
worker_processes 1;

events { worker_connections 64; }

http {
include /opt/homebrew/etc/nginx/mime.types;

server {
set $dir /path/to/jquery/repo/root;

# php-fpm endpoint
set $cgi 127.0.0.1:9000;

access_log /tmp/jquery_access.log;
error_log /tmp/jquery_error.log;

listen 80;
server_name localhost;

root $dir;

# enable POSTs to HTML
error_page 405 = $uri;
location @405 {
root $dir;
}

location ~ \.php {
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;

fastcgi_pass $cgi;
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jquery",
"title": "jQuery",
"description": "JavaScript library for DOM operations",
"version": "2.2.4",
"version": "2.2.5-sec",
"main": "dist/jquery.js",
"homepage": "http://jquery.com",
"author": {
Expand Down
7 changes: 7 additions & 0 deletions src/ajax/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ define( [
"../ajax"
], function( jQuery, document ) {

// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
jQuery.ajaxPrefilter( function( s ) {
if ( s.crossDomain ) {
s.contents.script = false;
}
} );

// Install script dataType
jQuery.ajaxSetup( {
accepts: {
Expand Down
3 changes: 2 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ jQuery.extend = jQuery.fn.extend = function() {
src = target[ name ];
copy = options[ name ];

// Prevent Object.prototype pollution
// Prevent never-ending loop
if ( target === copy ) {
if ( name === "__proto__" || target === copy ) {
continue;
}

Expand Down
7 changes: 2 additions & 5 deletions src/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ define( [
wrapMap, getAll, setGlobalEval, buildFragment, support,
dataPriv, dataUser, acceptData ) {

var
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,

// Support: IE 10-11, Edge 10240+
// In IE/Edge using regex groups here causes severe slowdowns.
// See https://connect.microsoft.com/IE/feedback/details/1736512/
rnoInnerhtml = /<script|<style|<link/i,
var rnoInnerhtml = /<script|<style|<link/i,

// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
Expand Down Expand Up @@ -226,7 +223,7 @@ function remove( elem, selector, keepData ) {

jQuery.extend( {
htmlPrefilter: function( html ) {
return html.replace( rxhtmlTag, "<$1></$2>" );
return html;
},

clone: function( elem, dataAndEvents, deepDataAndEvents ) {
Expand Down
6 changes: 6 additions & 0 deletions src/manipulation/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ define( [
// Make sure textarea (and checkbox) defaultValue is properly cloned
div.innerHTML = "<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;

// Support: IE <=9 only
// IE <=9 replaces <option> tags with their contents when inserted outside of
// the select element.
div.innerHTML = "<option></option>";
support.option = !!div.lastChild;
} )();

return support;
Expand Down
15 changes: 8 additions & 7 deletions src/manipulation/wrapMap.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
define( function() {
define( [
"./support"
], function( support ) {

// We have to close these tags to support XHTML (#13200)
var wrapMap = {

// Support: IE9
option: [ 1, "<select multiple='multiple'>", "</select>" ],

// XHTML parsers do not magically insert elements in the
// same way that tag soup parsers do. So we cannot shorten
// this by omitting <tbody> or other required elements.
Expand All @@ -17,11 +16,13 @@ var wrapMap = {
_default: [ 0, "", "" ]
};

// Support: IE9
wrapMap.optgroup = wrapMap.option;

wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;

// Support: IE <=9 only
if ( !support.option ) {
wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
}

return wrapMap;
} );
48 changes: 48 additions & 0 deletions test/unit/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,54 @@ QUnit.module( "ajax", {
};
} );

ajaxTest( "jQuery.ajax() - do not execute js (crossOrigin)", 2, function( assert ) {
return {
create: function( options ) {
options.crossDomain = true;
return jQuery.ajax( url( "data/script.php?header=ecma" ), options );
},
success: function() {
assert.ok( true, "success" );
},
complete: function() {
assert.ok( true, "complete" );
}
};
} );

ajaxTest( "jQuery.ajax() - execute js for crossOrigin when dataType option is provided", 3,
function( assert ) {
return {
create: function( options ) {
options.crossDomain = true;
options.dataType = "script";
return jQuery.ajax( url( "data/script.php?header=ecma" ), options );
},
success: function() {
assert.ok( true, "success" );
},
complete: function() {
assert.ok( true, "complete" );
}
};
}
);

ajaxTest( "jQuery.ajax() - do not execute js (crossOrigin)", 2, function( assert ) {
return {
create: function( options ) {
options.crossDomain = true;
return jQuery.ajax( url( "data/script.php" ), options );
},
success: function() {
assert.ok( true, "success" );
},
complete: function() {
assert.ok( true, "complete" );
}
};
} );

ajaxTest( "jQuery.ajax() - success callbacks (late binding)", 8, function( assert ) {
return {
setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess", assert ),
Expand Down
9 changes: 8 additions & 1 deletion test/unit/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ QUnit.test( "jQuery()", function( assert ) {
obj = jQuery( "div" ),
code = jQuery( "<code/>" ),
img = jQuery( "<img/>" ),
div = jQuery( "<div/><hr/><code/><b/>" ),
div = jQuery( "<div></div><hr/><code></code><b/>" ),
exec = false,
expected = 23,
attrObj = {
Expand Down Expand Up @@ -1228,6 +1228,13 @@ QUnit.test( "jQuery.extend(true,{},{a:[], o:{}}); deep copy with array, followed
assert.ok( !jQuery.isArray( result.object ), "result.object wasn't paved with an empty array" );
} );

QUnit.test( "jQuery.extend( true, ... ) Object.prototype pollution", function( assert ) {
assert.expect( 1 );

jQuery.extend( true, {}, JSON.parse( "{\"__proto__\": {\"devMode\": true}}" ) );
assert.ok( !( "devMode" in {} ), "Object.prototype not polluted" );
} );

QUnit.test( "jQuery.each(Object,Function)", function( assert ) {
assert.expect( 23 );

Expand Down
Loading