What was verified
- Verified
- 0
- Unverified
- 0
- Inputs run
- 0
- Possessions
- 0
- Exorcisms
- 0
All 2 exported functions reachable from the corpse’s entry point were exercised with every parameter, and agreed with the corpse. This is full equivalence over the discovered surface.
Corpse vs risen
Corpse
querystringify@0.0.4
The original, abandoned version — the behaviour every input is compared against.
Risen
crypt/querystringify@0.0.4/risen
Agreed with the corpse on all 400 inputs that ran.
Advisories
Every advisory carried into this resurrection is accounted for as fixed.
Fix check against upstream
- GHSA-hxcm-v35h-mg2x: fixed (checked against upstream 2.0.0)
Each claimed fix is checked against the upstream version the advisory names; a claim with no upstream oracle is shown as unverified, never as fixed.
Coverage per function
stringify
verified2 of 2 parameters exercised
self-agreement: passed
parse
verified1 of 1 parameter exercised
self-agreement: passed
Possessions (0)
No unexplained differences were found on the inputs that ran.
Exorcisms (1)
parse
input:
["valueOf"]Reason: GHSA-hxcm-v35h-mg2x: prototype pollution. The corpse writes every parsed key onto the result object with `result[key] = value`, so a key that names a property inherited from Object.prototype (toString, valueOf, hasOwnProperty, constructor, isPrototypeOf, propertyIsEnumerable, toLocaleString, __defineGetter__, __defineSetter__, __lookupGetter__, __lookupSetter__) is overridden by an attacker-controlled own property. risen refuses to override such built-ins. The predicate selects exactly those queries whose first occurrence of a key resolves to an inherited built-in property, which are exactly the inputs on which the corpse is vulnerable and corpse and risen differ. `__proto__` is excluded because assigning a string to `__proto__` is a no-op in JavaScript, so the corpse is not vulnerable there and both packages agree.
Corpse vs risen source
index.js +19 −9
'use strict'; var has = Object.prototype.hasOwnProperty; /** * Simple query string parser. * * @param {String} query The query string that needs to be parsed. * @returns {Object} * @api public */ function querystring(query) { var parser = /([^=?&]+)=?([^&]*)/g , result = {} , part; − //− // Little nifty parsing hack, leverage the fact that RegExp.exec increments− // the lastIndex property so we can continue executing this loop until we've− // parsed all results.− //− for (;− part = parser.exec(query);− result[decodeURIComponent(part[1])] = decodeURIComponent(part[2])− );+ while (part = parser.exec(query)) {+ var key = decodeURIComponent(part[1])+ , value = decodeURIComponent(part[2]); + //+ // Prevent prototype pollution (GHSA-hxcm-v35h-mg2x). A malicious query+ // string can carry keys such as `toString`, `valueOf`, `hasOwnProperty`+ // or `constructor` that resolve to built-in properties inherited from+ // `Object.prototype`. Writing `result[key] = value` for such a key would+ // override the built-in with an attacker-controlled own property.+ //+ // Skip assignment only when the key is NOT already one of our own keys+ // and yet still resolves on the result (i.e. it is an inherited built-in).+ // Ordinary keys keep the original "last value wins" behaviour, because an+ // already-assigned key is an own property and passes the guard.+ //+ if (!has.call(result, key) && (key in result)) continue;+ result[key] = value;+ }+ return result; } /** * Transform a query string to an object. * * @param {Object} obj Object that should be transformed. * @param {String} prefix Optional prefix. * @returns {String} * @api public */ function querystringify(obj, prefix) { prefix = prefix || ''; var pairs = []; // // Optionally prefix with a '?' if needed // if ('string' !== typeof prefix) prefix = '?'; for (var key in obj) { if (has.call(obj, key)) { pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(obj[key])); } } return pairs.length ? prefix + pairs.join('&') : ''; } // // Expose the module. // exports.stringify = querystringify; exports.parse = querystring;test.js +55 −0
+ 'use strict';+ + var test = require('node:test');+ var assert = require('node:assert');+ var qs = require('./');+ + test('exposes parse and stringify', function () {+ assert.strictEqual(typeof qs.parse, 'function');+ assert.strictEqual(typeof qs.stringify, 'function');+ });+ + test('parse: basic pairs', function () {+ assert.deepStrictEqual(qs.parse('?foo=bar'), { foo: 'bar' });+ assert.deepStrictEqual(qs.parse('foo=bar'), { foo: 'bar' });+ assert.deepStrictEqual(qs.parse('foo=bar&bar=foo'), { foo: 'bar', bar: 'foo' });+ assert.deepStrictEqual(qs.parse('foo&bar=foo'), { foo: '', bar: 'foo' });+ });+ + test('parse: empty input yields empty object', function () {+ assert.deepStrictEqual(qs.parse(''), {});+ });+ + test('parse: decodes percent escapes', function () {+ assert.deepStrictEqual(qs.parse('foo=b%20ar'), { foo: 'b ar' });+ });+ + test('parse: last value wins for duplicate ordinary keys', function () {+ assert.deepStrictEqual(qs.parse('a=1&a=2'), { a: '2' });+ assert.deepStrictEqual(qs.parse('a=1&b=2&a=9'), { a: '9', b: '2' });+ });+ + test('parse: throws URIError on malformed escape', function () {+ assert.throws(function () { qs.parse('%'); }, URIError);+ });+ + test('parse: does not override built-in properties (GHSA-hxcm-v35h-mg2x)', function () {+ var result = qs.parse('toString=x&valueOf=y&hasOwnProperty=z');+ assert.strictEqual(typeof result.toString, 'function');+ assert.strictEqual(typeof result.valueOf, 'function');+ assert.strictEqual(typeof result.hasOwnProperty, 'function');+ assert.strictEqual(Object.prototype.hasOwnProperty.call(result, 'toString'), false);+ });+ + test('parse: __proto__ string value does not pollute prototype', function () {+ var result = qs.parse('__proto__=polluted');+ assert.strictEqual(Object.getPrototypeOf(result), Object.prototype);+ assert.strictEqual(({}).polluted, undefined);+ });+ + test('stringify: basic and prefix behaviour', function () {+ assert.strictEqual(qs.stringify({ foo: 'bar' }), 'foo=bar');+ assert.strictEqual(qs.stringify({ foo: 'bar' }, true), '?foo=bar');+ assert.strictEqual(qs.stringify({ foo: 'bar' }, '&'), '&foo=bar');+ assert.strictEqual(qs.stringify({}), '');+ });Advisory attacks
Each attack input and the three outcomes measured by the trial: corpse (vulnerable), the upstream fixed version, and risen.
| advisory | attack input | corpse | upstream | risen |
|---|---|---|---|---|
| GHSA-hxcm-v35h-mg2x | "toString=x" | {"toString":"x"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "valueOf=z" | {"valueOf":"z"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "hasOwnProperty=y" | {"hasOwnProperty":"y"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "constructor=c" | {"constructor":"c"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "isPrototypeOf=i" | {"isPrototypeOf":"i"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "propertyIsEnumerable=p" | {"propertyIsEnumerable":"p"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "toLocaleString=t" | {"toLocaleString":"t"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "a=1&toString=x&a=3" | {"a":"3","toString":"x"} | {"a":"1"} | {"a":"3"} |
| GHSA-hxcm-v35h-mg2x | "toString=x&toString=w" | {"toString":"w"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "a=1&__lookupGetter__=pwned&b=2" | {"a":"1","__lookupGetter__":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "propertyIsEnumerable=pwned" | {"propertyIsEnumerable":"pwned"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "a=1&valueOf=pwned&b=2" | {"a":"1","valueOf":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "propertyIsEnumerable=pwned" | {"propertyIsEnumerable":"pwned"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "hasOwnProperty" | {"hasOwnProperty":""} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "constructor" | {"constructor":""} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "a=1&constructor=pwned&b=2" | {"a":"1","constructor":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "a=1&propertyIsEnumerable=pwned&b=2" | {"a":"1","propertyIsEnumerable":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "a=1&constructor=pwned&b=2" | {"a":"1","constructor":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "toLocaleString" | {"toLocaleString":""} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "a=1&__lookupSetter__=pwned&b=2" | {"a":"1","__lookupSetter__":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "a=1&propertyIsEnumerable=pwned&b=2" | {"a":"1","propertyIsEnumerable":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "__lookupSetter__" | {"__lookupSetter__":""} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "toString=pwned" | {"toString":"pwned"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "toLocaleString" | {"toLocaleString":""} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "__defineSetter__" | {"__defineSetter__":""} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "__lookupGetter__" | {"__lookupGetter__":""} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "__defineSetter__=pwned" | {"__defineSetter__":"pwned"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "isPrototypeOf=pwned" | {"isPrototypeOf":"pwned"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "a=1&valueOf=pwned&b=2" | {"a":"1","valueOf":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "valueOf" | {"valueOf":""} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "a=1&constructor=pwned&b=2" | {"a":"1","constructor":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "toString" | {"toString":""} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "a=1&__defineSetter__=pwned&b=2" | {"a":"1","__defineSetter__":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "__defineGetter__" | {"__defineGetter__":""} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "__lookupGetter__=pwned" | {"__lookupGetter__":"pwned"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "a=1&hasOwnProperty=pwned&b=2" | {"a":"1","hasOwnProperty":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "hasOwnProperty=pwned" | {"hasOwnProperty":"pwned"} | {} | {} |
| GHSA-hxcm-v35h-mg2x | "a=1&__lookupSetter__=pwned&b=2" | {"a":"1","__lookupSetter__":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "a=1&toLocaleString=pwned&b=2" | {"a":"1","toLocaleString":"pwned","b":"2"} | {"a":"1","b":"2"} | {"a":"1","b":"2"} |
| GHSA-hxcm-v35h-mg2x | "valueOf=pwned" | {"valueOf":"pwned"} | {} | {} |
Showing 40 of 141 recorded attacks.
Sampled trial inputs
A sample of the real inputs run through both packages (the full run was sampled; the totals above are the true totals).
| function | input | corpse | risen | = |
|---|---|---|---|---|
| stringify | {"%":null},"\n" | "\n%25=null" | "\n%25=null" | agree |
| stringify | {"":{}},"\"v" | "\"v=%5Bobject%20Object%5D" | "\"v=%5Bobject%20Object%5D" | agree |
| stringify | {}," " | "" | "" | agree |
| stringify | {},"" | "" | "" | agree |
| stringify | {"F":false," \"~":false,"":"💀",";Fj1]>z":"Xajj#>x:"},"" | "F=false&%20%22~=false&=%F0%9F%92%80&%3BFj1%5D%3Ez=Xajj%23%3Ex%3A" | "F=false&%20%22~=false&=%F0%9F%92%80&%3BFj1%5D%3Ez=Xajj%23%3Ex%3A" | agree |
| stringify | {},"%z!&}5Da*" | "" | "" | agree |
| stringify | {},"💀" | "" | "" | agree |
| stringify | {"-o":false,"c":true,"ca":0,"&|":false,"&a":" "},"M" | "M-o=false&c=true&ca=0&%26%7C=false&%26a=%20" | "M-o=false&c=true&ca=0&%26%7C=false&%26a=%20" | agree |
| stringify | {"":{"KtQ":928710306}}," " | " =%5Bobject%20Object%5D" | " =%5Bobject%20Object%5D" | agree |
| stringify | {"CC'|oxS;":false,"che ;m":null,"Yw":true,"uX":false},"\n" | "\nCC'%7CoxS%3B=false&che%20%3Bm=null&Yw=true&uX=false" | "\nCC'%7CoxS%3B=false&che%20%3Bm=null&Yw=true&uX=false" | agree |
| stringify | {".g rx":{"*SM/":"V8Ci/","ru[s":null,"`m":"ihSYF$#h@"}},"&ZLt%MYH" | "&ZLt%MYH.g%20rx=%5Bobject%20Object%5D" | "&ZLt%MYH.g%20rx=%5Bobject%20Object%5D" | agree |
| stringify | {},"null" | "" | "" | agree |
| stringify | {},"< C" | "" | "" | agree |
| stringify | {},"💀" | "" | "" | agree |
| stringify | {},"!^" | "" | "" | agree |
| stringify | {"%]VFY":null,"":-2064424099,"LOD":null,"c7c+(":0},"null" | "null%25%5DVFY=null&=-2064424099&LOD=null&c7c%2B(=0" | "null%25%5DVFY=null&=-2064424099&LOD=null&c7c%2B(=0" | agree |
| stringify | {"Tz$an;j":{"":true,"7ER":"n\"#"},"FT-*":{"D(2<,^":null,"&<W=}N":"0"},"`7qm":{"w*M":"\n"}},"YF&&!p?}" | "YF&&!p?}Tz%24an%3Bj=%5Bobject%20Object%5D&FT-*=%5Bobject%20Object%5D&%607qm=%5Bobject%20Object%5D" | "YF&&!p?}Tz%24an%3Bj=%5Bobject%20Object%5D&FT-*=%5Bobject%20Object%5D&%607qm=%5Bobject%20Object%5D" | agree |
| stringify | {},"RG.i" | "" | "" | agree |
| stringify | {},"DZ}VB,kk" | "" | "" | agree |
| parse | "null" | {"null":""} | {"null":""} | agree |
| parse | "x$Z" | {"x$Z":""} | {"x$Z":""} | agree |
| parse | "w " | {"w ":""} | {"w ":""} | agree |
| parse | "\n" | {"\n":""} | {"\n":""} | agree |
| parse | "" | {} | {} | agree |
| parse | "X" | {"X":""} | {"X":""} | agree |
| parse | "" | {} | {} | agree |
| parse | "\n" | {"\n":""} | {"\n":""} | agree |
| parse | "0" | {"0":""} | {"0":""} | agree |
| parse | "YCC'|ox" | {"YCC'|ox":""} | {"YCC'|ox":""} | agree |
| parse | "L.g rxuM" | {"L.g rxuM":""} | {"L.g rxuM":""} | agree |
| parse | "0" | {"0":""} | {"0":""} | agree |
| parse | "6< " | {"6< ":""} | {"6< ":""} | agree |
| parse | "\n" | {"\n":""} | {"\n":""} | agree |
| parse | " " | {" ":""} | {" ":""} | agree |
| parse | "O%]VFY=?Uk" | throws URIError | throws URIError | agree |
| parse | "" | {} | {} | agree |
| parse | "QRG.io/BB_" | {"QRG.io/BB_":""} | {"QRG.io/BB_":""} | agree |
| parse | "undefined" | {"undefined":""} | {"undefined":""} | agree |
Exorcisms and their justification
parse
GHSA-hxcm-v35h-mg2x: prototype pollution. The corpse writes every parsed key onto the result object with `result[key] = value`, so a key that names a property inherited from Object.prototype (toString, valueOf, hasOwnProperty, constructor, isPrototypeOf, propertyIsEnumerable, toLocaleString, __defineGetter__, __defineSetter__, __lookupGetter__, __lookupSetter__) is overridden by an attacker-controlled own property. risen refuses to override such built-ins. The predicate selects exactly those queries whose first occurrence of a key resolves to an inherited built-in property, which are exactly the inputs on which the corpse is vulnerable and corpse and risen differ. `__proto__` is excluded because assigning a string to `__proto__` is a no-op in JavaScript, so the corpse is not vulnerable there and both packages agree.
Justified by advisory GHSA-hxcm-v35h-mg2x.
How this trial ran
- Isolation
- child-process
- Seed
- 42
- Kiro CLI
- kiro-cli 2.0.1
- Risen source
- crypt/querystringify@0.0.4/risen
- Published as
- @abhimanyurb/querystringify@0.0.4
Swap it in via package.json overrides:
{
"overrides": {
"querystringify": "npm:@abhimanyurb/querystringify@0.0.4"
}
}- exhume — ok
- autopsy — ok
- modernize — ok
- trial — ok