Skip to content

Remote hooks called before ACL rules are applied #1191

Closed

Description

@kortac

Right now ACLs are called after before remote hook. That means this stack of calls:

  1. Before remote Hook
  2. ACL
  3. Remote method
  4. After remote hook
    I'd expect ACLs to be checked prior calling before remote hooks and not the other way round.

Example:

Event.beforeRemote("prototype.__unlink__guests", function(ctx, modelInstance, next){
    console.log("before remote hook");
    next();
});

with this ACL

{
  "accessType": "*",
  "principalType": "ROLE",
  "principalId": "$everyone",
  "permission": "DENY",
  "property": "__unlink__guests"
}

Even though the Loopback explorer displays a 401 error, the console displays "before remote hook". In my opinion, this should not be the case.

Activity

  1. raymondfeng commented on Mar 9, 2015

    @raymondfeng
    Member

    @ritch ACL check is done from one of the remote hooks. Can we ensure it's called before any other remote hooks?

  2. ritch commented on Mar 9, 2015

    @ritch
    Member

    If you create the hook after boot it should run in the expected order.

  3. fabien commented on Apr 25, 2015

    @fabien
    Contributor

    @raymondfeng @ritch I think the expected behavior would be to have the ACL check be the first call in the stack. Or at least it should be configurable to work that way. It has some pretty serious implications, if you're not aware of this right now!

  4. fabien commented on Apr 25, 2015

    @fabien
    Contributor

    @raymondfeng @ritch I strongly believe this should be fixed ASAP. Any before remote hook defined at the models/model.js or mixin level will just execute the before hook without any regard to ACL checks. This is a security disaster waiting to happen.

  5. changed the title [-]ACLs called after before hook[/-] [+]Remote hooks called before ACL rules are applied[/+] on Apr 28, 2015
  6. ghost removed on May 5, 2015
  7. ghost added on May 5, 2015
  8. ghost removed on May 6, 2015
  9. ghost changed the title [-]Remote hooks called before ACL rules are applied[/-] [+]70 Remote hooks called before ACL rules are applied[/+] on May 6, 2015
  10. ghost changed the title [-]70 Remote hooks called before ACL rules are applied[/-] [+]A Remote hooks called before ACL rules are applied[/+] on May 6, 2015
  11. ghost changed the title [-]A Remote hooks called before ACL rules are applied[/-] [+]70 Remote hooks called before ACL rules are applied[/+] on May 6, 2015
  12. ghost changed the title [-]70 Remote hooks called before ACL rules are applied[/-] [+]Remote hooks called before ACL rules are applied[/+] on May 6, 2015
  13. ritch commented on May 6, 2015

    @ritch
    Member

    @fabien agreed. I've implemented this as both a new feature (a new authorization hook) and a fix (ensuring we use this hook instead of adding blindly as a remotes.before() hook).

    See #1370

  14. fabien commented on May 6, 2015

    @fabien
    Contributor

    @ritch thanks!

  15. ritch commented on May 12, 2015

    @ritch
    Member

    @Toreader @fabien fixed @ 2.17.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions