All the vulnerabilities related to the version 7.3.1 of the package
cookie accepts cookie name, path, and domain with out of bounds characters
The cookie name could be used to set other fields of the cookie, resulting in an unexpected cookie value. For example, serialize("userName=<script>alert('XSS3')</script>; Max-Age=2592000; a", value)
would result in "userName=<script>alert('XSS3')</script>; Max-Age=2592000; a=test"
, setting userName
cookie to <script>
and ignoring value
.
A similar escape can be used for path
and domain
, which could be abused to alter other fields of the cookie.
Upgrade to 0.7.0, which updates the validation for name
, path
, and domain
.
Avoid passing untrusted or arbitrary values for these fields, ensure they are set by the application instead of user input.
devalue prototype pollution vulnerability
devalue.parse
allows __proto__
to be setA string passed to devalue.parse
could represent an object with a __proto__
property, which would assign a prototype to an object while allowing properties to be overwritten:
class Vector {
constructor(x, y) {
this.x = x;
this.y = y;
}
get magnitude() {
return (this.x ** 2 + this.y ** 2) ** 0.5;
}
}
const payload = `[{"x":1,"y":2,"magnitude":3,"__proto__":4},3,4,"nope",["Vector",5],[6,7],8,9]`;
const vector = devalue.parse(payload, {
Vector: ([x, y]) => new Vector(x, y)
});
console.log("Is vector", vector instanceof Vector); // true
console.log(vector.x) // 3
console.log(vector.y) // 4
console.log(vector.magnitude); // "nope" instead of 5
devalue.parse
allows array prototype methods to be assigned to objectIn a payload constructed with devalue.stringify
, values are represented as array indices, where the array contains the 'hydrated' values:
devalue.stringify({ message: 'hello' }); // [{"message":1},"hello"]
devalue.parse
does not check that an index is numeric, which means that it could assign an array prototype method to a property instead:
const object = devalue.parse('[{"toString":"push"}]');
object.toString(); // 0
This could be used by a creative attacker to bypass server-side validation.