-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Fix Has Privilege API check on restricted indices #41226
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
Fix Has Privilege API check on restricted indices #41226
Conversation
Pinging @elastic/es-security |
@tvernum you are right that the 400 error is not suitable for a fix in a patch version. I and @jkakavas gathered and decided it's better to do the proper check on the restricted indices ( |
@jkakavas this is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
set to `true`. By default this is `false` because restricted indices should | ||
generaly not be "visible" to APIs. For most use cases it is safe to ignore | ||
this parameter. | ||
`allow_restricted_indices`::: (boolean) This needs to be set to `true` (default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth adding one sentence in the end, something like "If restricted indices are explicitly included in the names
list, privileges will be checked against them regardless of the value of allow_restricted_indices
" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea, I've amended the description as you suggested.
@elasticmachine run elasticsearch-ci/1 |
@elasticmachine run elasticsearch-ci/1 |
@elasticmachine run elasticsearch-ci/1 |
The Has Privileges API allows to tap into the authorization process, to validate privileges without actually running the operations to be authorized. This commit fixes a bug, in which the Has Privilege API returned spurious results when checking for index privileges over restricted indices (currently .security, .security-6, .security-7). The actual authorization process is not affected by the bug.
The Has Privileges API allows to tap into the authorization process, to validate privileges without actually running the operations to be authorized. This commit fixes a bug, in which the Has Privilege API returned spurious results when checking for index privileges over restricted indices (currently .security, .security-6, .security-7). The actual authorization process is not affected by the bug.
The Has Privileges API allows to tap into the authorization process, to validate privileges without actually running the operations to be authorized. This commit fixes a bug, in which the Has Privilege API returned spurious results when checking for index privileges over restricted indices (currently .security, .security-6, .security-7). The actual authorization process is not affected by the bug.
The Has Privileges API allows to tap into the authorization process, to validate privileges without actually running the operations to be authorized. This commit fixes a bug, in which the Has Privilege API returned spurious results when checking for index privileges over restricted indices (currently .security, .security-6, .security-7). The actual authorization process is not affected by the bug.
The Has Privileges API allows to tap into the authorization process, to validate privileges without actually running the operations to be authorized. This commit fixes a bug, in which the Has Privilege API returned spurious results when checking for index privileges over restricted indices (currently .security, .security-6, .security-7). The actual authorization process is not affected by the bug.
The Has Privileges API allows to tap into the authorization process, to validate privileges without actually running the operations to be authorized. This fixes a bug, uncovered by Tim, in which the Has Privilege API returned spurious results when checking for index privileges over restricted indices (currently
.security
,.security-6
,.security-7
). The actual authorization process is not affected by the bug.Wildcards of index names in the Has Privileges's request do not implicitly cover restricted indices. Concretely, calling:
and getting back a response such as:
Does not mean the user is authorized to read the indices
.security
,.security-6
,.security-7
, even though the output says.security*: { "read": true }
(and these indices match the wildcard). They might, or they might not, depending on the permissions definition. Implicitly, the API assumes the caller is not interested on privileges over these indices so the wildcard is not considering them.If the caller is interested in privileges over these restricted indices, it should change the request as such:
And now the wildcards expand to include the special indices. If the response is
true
(the same response as above), the the read operation is indeed authorized on.security
,.security-6
,.security-7
.Passing the
allow_restricted_indices
is required even when checking privileges using explicit index names (no wildcards). And this is where the bug manifested: basically the result was bogus when explicitly checking privileges over restricted indices explicitly mentioned, but without setting theallow_restricted_indices
flag.The fix treats explicit restricted indices, without theallow_restricted_indices: true
flag, in the request, as anIllegalArgumentException
(400 error). If the flag is specified, the API correctly validates the privilege.