-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Hash injection (security) #7310
Copy link
Copy link
Closed
Labels
docsFor issues and PRs. Things related to documentation, such as changes in the manuals / API reference.For issues and PRs. Things related to documentation, such as changes in the manuals / API reference.status: in discussionFor issues and PRs. Community and maintainers are discussing the applicability of the issue.For issues and PRs. Community and maintainers are discussing the applicability of the issue.
Metadata
Metadata
Assignees
Labels
docsFor issues and PRs. Things related to documentation, such as changes in the manuals / API reference.For issues and PRs. Things related to documentation, such as changes in the manuals / API reference.status: in discussionFor issues and PRs. Community and maintainers are discussing the applicability of the issue.For issues and PRs. Community and maintainers are discussing the applicability of the issue.
Using specially crafted requests we can trivially bypass secret_token protections on websites using sequalize.
Many people have code like this
But Node.js and other platforms allow nested parameters, ie token[$gt]=1 will turn into token = {"$gt":1}. When we pass such hash to sequalize it will consider it a query (greater than 1) and find the first token in DB, bypassing security of this endpoint. This behavior was copied from Mongo https://docs.mongodb.com/manual/reference/operator/query/
Using finely tuned $gt we can iterate all tokens in db and impersonate every single user.
There are vulnerable sites in the wild.
That's how it can be exploited in Mongo http://blog.websecurify.com/2014/08/hacking-nodejs-and-mongodb.html and https://cirw.in/blog/hash-injection
My advice would be to either disable this functionality entirely (i.e. require passing token {"$eq":token} every time) or make sure the parameter isn't coming from req.query and is native hash object.