require_admin_context() does not account for policy.json rulesets

Bug #1447164 reported by Sylvain Bauza on 2015-04-22
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)

Bug Description

The API RBAC is done using a policy.json file which allows fine-grained control over each API endpoint by setting specific rules.
Consequently, some defaulted admin-only endpoints can be opened by modifying their corresponding policy rules to be for anyone.

Unfortunately, in many places (in the DB and at the API level following the blueprint api-policy-v3 ), there is a call to context.require_admin_context() which is just checking if the user is admin or no but doesn't match with the policy rules.

As we all agreed with api-policy-v3 that RBAC should be done at the API level, there is no reason to keep that call to context.require_admin_context() and we should assume that policy.json is the single source of truth for knowing the access rights.

Changed in nova:
importance: Undecided → Medium
jichenjc (jichenjc) wrote :

Only wondering whether some operators utilize the admin check before so
the not allowed operations will became allowed now

the api-policy-v3 aims to backward compatible but this need Doc update and operator need to be awared?

Matt Riedemann (mriedem) wrote :

I don't disagree, see bug 1168488 from way back in grizzly.

The only thing would be we'd have to make sure the default rule is admin for any v2 extensions which are enforcing an admin context today.

Changed in nova:
status: New → Confirmed
tags: added: low-hanging-fruit
Changed in nova:
assignee: nobody → Zhenyu Zheng (zhengzhenyu)
Changed in nova:
assignee: Zhenyu Zheng (zhengzhenyu) → Diana Clarke (diana-clarke)
Diana Clarke (diana-clarke) wrote :

There are currently 41 calls to require_admin_context:


All of them are in:


Each one of those calls is prefixed by a similar comment:

        # NOTE(alex_xu): back-compatible with db layer hard-code admin
        # permission checks.

And this comment addresses the question this bug raises:

        # NOTE(alex_xu): back-compatible with db layer hard-code admin
        # permission checks. This has to be left only for API v2.0 because
        # this version has to be stable even if it means that only admins
        # can call this method while the policy could be changed.

I suspect (but I could be wrong) that there was consensus to stop here with these API policy/permission check changes.

Can someone please confirm that the direction this bug proposes is still desired? Thanks!

If not... then we can close this bug.

Alex Xu (xuhj) wrote :

Actually in the original spec, we said keep the v2 API behavior as the same

So we add back-compatible check to the legacy v2 API. And this legacy v2 API already deprecated, so I think it's worth to do it.

I prefer to close the bug...

Diana Clarke (diana-clarke) wrote :

Thanks for the additional context, Alex. I'll close this bug (mark it as invalid).

Changed in nova:
status: Confirmed → Invalid
assignee: Diana Clarke (diana-clarke) → nobody
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers