Policy rule position errors

Bug #1384377 reported by Andre Aranha
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Invalid
Undecided
Unassigned
oslo.policy
Triaged
Medium
Ian Cordasco

Bug Description

In the policy.v3cloudsample.json there is the rule "admin_or_owner" that is defined as "(rule:admin_required and domain_id:%(target.token.user.domain.id)s) or rule:owner", and the tests for it ( https://github.com/openstack/keystone/blob/master/etc/policy.v3cloudsample.json#L7 ) , specially this keystone.tests.test_v3_auth.TestTokenRevokeSelfAndAdmin.test_user_revokes_own_token shows it's working as expected. The rule "admin_required" is defined only as "role:admin" ( https://github.com/openstack/keystone/blob/master/etc/policy.v3cloudsample.json#L2 ), so I changed the rule "admin_or_owner" to "(role:admin and domain_id:%(target.token.user.domain.id)s) or rule:owner" and the test raises a error saying that the user has no permission to do the action. As it's the same rule, it wasn't suppose to raise errors. But it doesn't stop there, when I rearrange the rule order to be like this: "admin_or_owner": "rule:owner or (role:admin and domain_id:%(target.token.user.domain.id)s)" it works.

Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

This sounds like a bug in the way the rules processor is working. This may not actually be a bug in keystone but a bug in the oslo policy library or a way we're invoking the enforcer.

I'm curious what happens in the case the token matches rule:admin and domain_id" in the second case.

Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

I've dug into this issue a bunch now, this looks to be a policy engine issue. As soon as we've graduated the engine I'm going to move this bug over there. I'm going to leave this bug under keystone so i don't loose it for now.

Revision history for this message
Andre Aranha (afaranha) wrote :

Sure, makes sense to me :)

Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

This is not a keystone bug.

Changed in keystone:
status: New → Invalid
Changed in oslo.policy:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

I've done a number of tests and cannot get this to fail in an unsafe manner. It is a bug in rule processing order and an incorrect short-circut-to-fail as far as I can tell.

Ian Cordasco (icordasc)
Changed in oslo.policy:
assignee: nobody → Ian Cordasco (icordasc)
Revision history for this message
Ian Cordasco (icordasc) wrote :

I can't seem to reproduce this on master: http://paste.openstack.org/show/178715/ (that script prints True for different sets of credentials).

Changed in oslo.policy:
status: Triaged → Incomplete
Revision history for this message
Ian Cordasco (icordasc) wrote :

Ah, I misread the bug description.

Changed in oslo.policy:
status: Incomplete → Confirmed
Changed in oslo.policy:
status: Confirmed → Triaged
Revision history for this message
Akira Yoshiyama (yosshy) wrote :

Bug #1523030 looks duplicate to this one.
Andre, could you try a commit below?

https://review.openstack.org/#/c/253763/

Revision history for this message
Matthew Edmonds (edmondsw) wrote :

I hit this with oslo.policy 0.5.0, but I'm not seeing it in 1.3.0. I do believe it was fixed by https://review.openstack.org/#/c/253763/

Revision history for this message
Steve Martinelli (stevemar) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.