loopback icon indicating copy to clipboard operation
loopback copied to clipboard

find always executed for updateAttributes, even if the ACL not allowing to access the updateAttributs remotemethod

Open zkuang opened this issue 10 years ago • 5 comments

setup the find logic as:

module.exports = function(Product) {

Product.on('dataSourceAttached', function(obj) {
    var find = Product.find;
    Product.find = function(filter, option, callback) {
        console.log('find executed');
        find.call(this, filter, option, callback);
    }
}); 

};

The ACL: "acls": [ { "accessType": "*", "principalType": "ROLE", "principalId": "$everyone", "permission": "DENY" } ],

Try to put to /api/Products/anyid, and I can see the log: find executed. Would it be a security issue?

zkuang avatar Jun 02 '16 09:06 zkuang

Hello @zkuang, thank you for reporting the issue. AFAIK, when you call invoke prototype.updateAttributes via REST API, we are calling find with a filter { where: { id: <id> } } to find the instance you would like to update. I don't see why it would be a security issue, but I may be wrong. Could you please elaborate little bit more on what is your thinking?

bajtos avatar Jun 02 '16 12:06 bajtos

I'm not sure if this matters that much. The concern is this gives an unauthorized user the privilege to execute code that's not granted to him since the find method is not permitted to be executed for that user. At least, he would know some Product ID doesn't exist if he gets back a 404.

zkuang avatar Jun 02 '16 14:06 zkuang

Hey @zkuang, I'm closing this issue in favor of strongloop/strong-remoting#311 as the fix must be made in that repository.

Thanks for contributing!

richardpringle avatar Jun 07 '16 14:06 richardpringle

@bajtos regarding strongloop/loopback#2220 it is an information leak, where model ids can be iterated to check for model existence. this might be necessary information for further attack.

michaelfreund avatar Jun 07 '16 14:06 michaelfreund

Thanks @michaelfreund . I'll follow up.

zkuang avatar Jun 13 '16 06:06 zkuang