Skip to content
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

Fix prototype pollution #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions jquery.ba-bbq.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,13 @@
* http://benalman.com/about/license/
*/

/*
* Additional changes to this file:
* - Fixed prototype pollution (CVE-2021-20086)
* - Minified with `uglifyjs jquery.ba-bbq.js --compress -o jquery.ba-bbq.min.js`
* http://benalman.com/about/license/
*/

// Script: jQuery BBQ: Back Button & Query Library
//
// *Version: 1.3pre, Last updated: 8/26/2010*
@@ -465,6 +472,7 @@

$.deparam = jq_deparam = function( params, coerce ) {
var obj = {},
prohibited_keys = ['__proto__'],
coerce_types = { 'true': !0, 'false': !1, 'null': null };

// Iterate over all name=value pairs.
@@ -479,6 +487,10 @@
// into its component parts.
keys = key.split( '][' ),
keys_last = keys.length - 1;

if ( prohibited_keys.includes( key ) ) {
return;
}

// If the first keys part contains [ and the last ends with ], then []
// are correctly balanced.
@@ -520,6 +532,11 @@
// * Rinse & repeat.
for ( ; i <= keys_last; i++ ) {
key = keys[i] === '' ? cur.length : keys[i];

if ( prohibited_keys.includes( key ) ) {
return;
}

cur = cur[key] = i < keys_last
? cur[key] || ( keys[i+1] && isNaN( keys[i+1] ) ? {} : [] )
: val;
19 changes: 1 addition & 18 deletions jquery.ba-bbq.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.