Skip to content

App permissions with action patterns do not retrieve privileges #85455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

albertzaharovits
Copy link
Contributor

@albertzaharovits albertzaharovits commented Mar 29, 2022

In order for file realm users, with application privileges, to continue
to work (authenticate) when the .security index is unavailable,
Security must avoid loading the application privileges from the .security index
(which is unavailable, hence error out).
Roles (defined inside the roles.yml file, not in the index) that must work
when the .security index is unavailable must use inlined action patterns
for application permisions, rather than privilege names.

Related #85312

@albertzaharovits albertzaharovits self-assigned this Mar 29, 2022
@albertzaharovits albertzaharovits marked this pull request as ready for review March 29, 2022 16:06
@elasticmachine elasticmachine added the Team:Security Meta label for security team label Mar 29, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

Copy link
Contributor

@justincr-elastic justincr-elastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would need more information to be able to complete a review, but I did have a feedback point.

try {
ApplicationPrivilege.validatePrivilegeOrActionName(action);
ApplicationPrivilege.validateActionName(action);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it confusing to have a method called validateActionName which does validation on action name, but then also calls through to validatePrivilegeOrActionName.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you also have proposals to improve it?
Also keeping in mind this is a bug-fix PR.
I only slightly changed code in this part to make sure the action names I generate IN TESTS are valid.

@albertzaharovits
Copy link
Contributor Author

albertzaharovits commented Mar 30, 2022

This PR fixes the bug from #85312 by making any file-based role that contains application permissions that do not refer to named application privileges (which only mention inlined action patterns, like the superuser role does) not unnecessarily query the .security index. By avoiding querying the index, such roles can be used even when the index is unavailable.

Another option to fix the same bug would be to always return the statically built superuser role, after failing to resolve a role name list that includes it. We do something like that today, when failing to retrieve any role descriptors, but not when failing to retrieve privileges referred in those role descriptors.

I think both approaches have pros-cons, but I don't think we have to choose between them.
I think it is perfectly reasonable for file-based roles to not reach the index if they don't need to, but if they do, and fail, we should not fail the authentication if the user also has superuser.


EDIT:

The above has been partly discussed over Slack, and the other option has been suggested by @tvernum .

@elasticsearchmachine
Copy link
Collaborator

Hi @albertzaharovits, I've created a changelog YAML for you.

@tvernum
Copy link
Contributor

tvernum commented Apr 11, 2022

Hey @albertzaharovits - this approach looks like a good direction to me.
Are you still looking for a review?

Copy link
Contributor

@justincr-elastic justincr-elastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@elasticsearchmachine
Copy link
Collaborator

Hi @albertzaharovits, I've updated the changelog YAML for you.

@albertzaharovits
Copy link
Contributor Author

Hey @albertzaharovits - this approach looks like a good direction to me.
Are you still looking for a review?

Yes, please review. I have adapted the PR description and label to reflect that this is now >enhancement rather than a >bug fix after you have merged #85519 .

@tvernum
Copy link
Contributor

tvernum commented May 20, 2022

Given this is now an enhancement, I don't think we should backport to 7.17

Copy link
Contributor

@tvernum tvernum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@albertzaharovits
Copy link
Contributor Author

@elasticmachine update branch

@albertzaharovits albertzaharovits added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Jun 5, 2022
@elasticsearchmachine elasticsearchmachine merged commit f4b720e into elastic:master Jun 5, 2022
@albertzaharovits albertzaharovits deleted the file-based-superuser branch June 5, 2022 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >enhancement :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC Team:Security Meta label for security team v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants