-
Notifications
You must be signed in to change notification settings - Fork 96
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
$populate security risk #207
Comments
You can always write a hook to prevent this however I agree that |
Agreed. I've been debating of disabling anything that is not covered by the official query syntax by default and having to explicitly whitelist the functionality you want. We're planning major releases for the database adapters for feathersjs/feathers#608 so that might be a good time to do that. |
imho Using the internal mongoose |
I agree with @ekryski. I don't think disabling a query param is the best solution. However, creating a before/after populate callback per service sounds flexible and reasonable enough to address the security concerns. |
There is a hook that disables populate for the moment? |
function(hook) {
delete hook.params.query.$populate;
} ? |
it works, I added that in the find and get before in the app.hooks.js |
If you still want that functionality in the backend you can use this hook // Disables mongoose $populate in the front
const { when } = require('feathers-hooks-common')
module.exports = () => {
return when(
hook => hook.params.provider,
hook => {
delete hook.params.query.$populate
return hook
}
)
} |
@daffl Just ran in to this problem. I want to use the populate feature, however using the Edit: At the moment I'm just including the removal of the sensitive data in a hook that serializes it into JSON-API format. I don't understand why |
What I said in my previous comment. Just |
Steps to reproduce
Following scenario:
I got two services : "comments" and "users".
Users is the private service which holds the user data and can only be accessed if authorized.
Comments is a public endpoint and serves datasets containing a ObjectRef to the user that created the comment.
Now i do a "comments?$populate[]=user"
Expected behavior
It should not give me the complete user dataset without being authorized as this user
Actual behavior
It does give me everything. How can i get it secure?
System configuration
The text was updated successfully, but these errors were encountered: