[BUG] Prototype Override Protection Bypass
larrycameron80 opened this issue · 3 comments
Prototype Override Protection Bypass
Vulnerable module: qs
Introduced through: koa-qs@2.0.0
Detailed paths
Introduced through: data-service@wavesplatform/data-service#7f17ec615f4a24958b074bfbdaeb6582cc22d1a9 › koa-qs@2.0.0 › qs@2.3.3
Overview
qs is a querystring parser that supports nesting and arrays, with a depth limit.
By default qs protects against attacks that attempt to overwrite an object's existing prototype properties, such as toString(), hasOwnProperty(),etc.
From qs documentation:
By default parameters that would overwrite properties on the object prototype are ignored, if you wish to keep the data from those fields either use plainObjects as mentioned above, or set allowPrototypes to true which will allow user input to overwrite those properties. WARNING It is generally a bad idea to enable this option as it can cause problems when attempting to use the properties that have been overwritten. Always be careful with this option.
Overwriting these properties can impact application logic, potentially allowing attackers to work around security controls, modify data, make the application unstable and more.
In versions of the package affected by this vulnerability, it is possible to circumvent this protection and overwrite prototype properties and functions by prefixing the name of the parameter with [ or ]. e.g. qs.parse("]=toString") will return {toString = true}, as a result, calling toString() on the object will throw an exception.
Example:
qs.parse('toString=foo', { allowPrototypes: false })
// {}
qs.parse("]=toString", { allowPrototypes: false })
// {toString = true} <== prototype overwritten
Thank you for the report, will fix soon.
Awesome, thanks dvshur!