-
Notifications
You must be signed in to change notification settings - Fork 1.8k
JS: remove the second argument of findByIdAndUpdate as a NoSQL sink #13381
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
Conversation
I remember also being surprised at this when porting the SQL models to MaD. As far as I understand, Mongoose lets you use MongoDB update operators in updates, so they are sinks for the same reason they are sinks in MongoDB. |
The documentation states: So should the second argument just be removed for those methods? |
The issue with |
d504c93
to
95c02db
Compare
QHelp previews: |
I see. I get it now. I rebased away the part about removing the second argument of |
95c02db
to
cd6f738
Compare
Sorry for the spurious Python ping. My local |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
2 things:
I was looking at
findByIdAndUpdate
, and I was surprised we flag the second argument as a NoSQL sink.See doc: https://mongoosejs.com/docs/tutorials/findoneandupdate.html. The second argument is the data given to the update function, so I'm unsure how that could be unsafe?
A friend of mine likes to use
mongoose.Types.ObjectId.isValid
as a sanitizer for NoSQL injection.The function checks if an input is a string of a certain length, so it is a nice sanitizer for object-injection in general.
I therefore decided to put it in
TaintedObject.qll
, let me know if you want it somewhere else.The function is used a decent amount in the wild.
Evaluation looks good.
There is one lost result, where we no longer flag the second argument on a call to
update
.(We still flag the first argument to that same call).