Skip to content

circular link will make getImplicitRolesForUser stackoverflow #150

Closed
@0x8f701

Description

@0x8f701

mode.conf

[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && regexMatch(r.act, p.act)
p, book_admin , /book/1, GET
p, pen_admin , /pen/1, GET

g, *, book_admin 
g, *, pen_admin

patten matching func:

keyMatch

error: e.getImplicitRolesForUser("alice") will cause stackoverflow

What's happening

Step1: Since we have pattern matching function and alice match *, then when we createRole alice will add * in her role list. While calling e.getImplicitRolesForUser("alice").

The first loop, we will get alice's direct role list:

["*"]

Step2: Then we call e.getImplicitRolesForUser("*"), and in its first iteration we get the following role list:

["book_admin", "pen_admin"]

Step3: Then we call e.getImplicitRolesForUser("book_admin") and e.getImplicitRolesForUser("pen_admin"), it founds book_admin matches * then it returns also * and the next call will return to our step1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions