-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
hgetall mishandles malicious keys (__proto__) #1267
Comments
Veracode reported the package for this vulnerability. From the issue description, I believe this wouldn't impact the applications that aren't directly allowing user-provided field names. Adding link to Veracode SCA finding page for list of vulnerable versions: It would be great to see a fix as suggested by @davidje13 in the issue in the upcoming versions. Thanks. |
🎉 This issue has been resolved in version 4.27.8 🎉 The release is available on: Your semantic-release bot 📦🚀 |
* the previously used version of ioredis was vulnerable to a prototype pollution attack: redis/ioredis#1267
* the previously used version of ioredis was vulnerable to a prototype pollution attack: redis/ioredis#1267
* the previously used version of ioredis was vulnerable to a prototype pollution attack: redis/ioredis#1267
the previously used version of ioredis was vulnerable to a prototype pollution attack: redis/ioredis#1267
## [4.27.8](redis/ioredis@v4.27.7...v4.27.8) (2021-08-18) ### Bug Fixes * handle malicious keys for hgetall ([#1416](redis/ioredis#1416)) ([7d73b9d](redis/ioredis@7d73b9d)), closes [#1267](redis/ioredis#1267)
This isn't a global prototype pollution attack, but does mean it's possible to get inconsistent behaviour:
It's because the reply transformer which is applied does not check for special field names: https://github.com/luin/ioredis/blob/master/lib/command.ts#L404
Since this isn't doing a recursive set, it can't cause global prototype pollution, but it can cause unexpected inconsistent behaviour as shown above. Obviously this is mainly a concern if allowing user-provided field names (e.g. a database explorer UI). Since the database itself can handle this name, I think the client library should be able to handle it too.
The easiest fix would be something like:
But a better fix would be to change the API to return a
Map
instead.None of the other commands seem to have the same issue;
hgetall
is the only command which usessetReplyTransformer
, and theArgumentTransformer
s are fine (e.g.hset('foo', JSON.parse('{"__proto__":"yay"}'))
works)Relatedly, it would be nice to be able to call
hgetall
without the reply transformer (returning a raw key/value alternating list) for situations where the intent is to iterate through all fields anyway. It's interesting that the transformer has a condition checking for arrays; is it possible for the server to send a different data type? The main documentation says it will always be a list.The text was updated successfully, but these errors were encountered: