Skip to content
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

Restrict run-as to realm and api_key authentication types #84336

Merged
merged 3 commits into from
Feb 28, 2022

Conversation

ywangd
Copy link
Member

@ywangd ywangd commented Feb 24, 2022

This PR removes run-as support for authentication types other than realm
and API key. The change essentially makes the behaviour closer to
the existing one (in released versions) except for API keys. This is not
to say that the existing behaviour is the best. But we need more time to
agree on the new behaviour.

Relates: #79809

This PR removes run-as support for authentication types other than realm
and API key. The change essentially makes the behaviour closer to
the existing one (in released versions) except for API keys. This is not
to say that the existing behaviour is the best. But we need more time to
agree on the new behaviour.

Relates: elastic#79809
@ywangd ywangd added >non-issue :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v8.1.0 v8.2.0 labels Feb 24, 2022
@elasticmachine elasticmachine added the Team:Security Meta label for security team label Feb 24, 2022
@elasticmachine
Copy link
Collaborator

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

Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 211 to 214
logger.info(
"ignore run-as header since it is not supported for authentication type [{}]",
authentication.getAuthenticationType().name().toLowerCase(Locale.ROOT)
);
Copy link
Member Author

Choose a reason for hiding this comment

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

Logging at INFO level instead of WARN to avoid causing unnecessary worries. Also didn't add warning to response header because I am not sure whether it would be another unpleasant experience in Kibana (warning message spamming in dashboard etc).

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like a safe choice, but when we decide what to do in 8.2 we'll need to take into account that we've ignored the headers up until this point (without warning).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it's a tricky situation. Even supporting API key run-as in this release has this same issue. It's in a gray area of "breaking change" vs "bug fix" vs "feature". It's probably a stretch to call it a "bug fix" since we intentionally not supporting things like token. But I also really don't think it should be breaking. I'll tweak the logging message a little bit to say:

"... it is currently not supported ..." to indicate the support might be coming.

This subtlety might not be that useful. It is definitely not officical because it is not a proper deprecation message or anything. But we don't have such tooling right now. So some subtlety in the wording might be our best bet right now.

Comment on lines 211 to 214
logger.info(
"ignore run-as header since it is not supported for authentication type [{}]",
authentication.getAuthenticationType().name().toLowerCase(Locale.ROOT)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like a safe choice, but when we decide what to do in 8.2 we'll need to take into account that we've ignored the headers up until this point (without warning).

@ywangd ywangd merged commit c0fb9c9 into elastic:master Feb 28, 2022
ywangd added a commit to ywangd/elasticsearch that referenced this pull request Feb 28, 2022
Creating tokens using API keys is not properly supported till elastic#80926.
Previously the created token always has no previlege. Now the token has
the same privilege as the API key itself (similar to user created
tokens). Authenticating using the token is considered equivalent to the
API key itself. Therefore the "isApiKey" check needs to be updated to
cater for both authentications of API key itself and the token created
by the API key.

This PR updated the isApiKey check and apply it consistently to ensure
the behaviour is consistent between an API key and a token created by
it.

The only exception is for supporting run-as. API key itself can run-as
another user. But a token created by the API key cannot perform run-as
(elastic#84336) similar to how user/token works.
ywangd added a commit to ywangd/elasticsearch that referenced this pull request Feb 28, 2022
)

This PR removes run-as support for authentication types other than realm
and API key. The change essentially makes the behaviour closer to
the existing one (in released versions) except for API keys. This is not
to say that the existing behaviour is the best. But we need more time to
agree on the new behaviour.

Relates: elastic#79809
ywangd added a commit that referenced this pull request Feb 28, 2022
…84399)

This PR removes run-as support for authentication types other than realm
and API key. The change essentially makes the behaviour closer to
the existing one (in released versions) except for API keys. This is not
to say that the existing behaviour is the best. But we need more time to
agree on the new behaviour.

Relates: #79809
ywangd added a commit that referenced this pull request Feb 28, 2022
Creating tokens using API keys is not properly supported till #80926.
Previously the created token always has no previlege. Now the token has
the same privilege as the API key itself (similar to user created
tokens). Authenticating using the token is considered equivalent to the
API key itself. Therefore the "isApiKey" check needs to be updated to
cater for both authentications of API key itself and the token created
by the API key.

This PR updates the isApiKey check and apply it consistently to ensure
the behaviour is consistent between an API key and a token created by
it.

The only exception is for supporting run-as. API key itself can run-as
another user. But a token created by the API key cannot perform run-as
(#84336) similar to how user/token works.
ywangd added a commit to ywangd/elasticsearch that referenced this pull request Feb 28, 2022
Creating tokens using API keys is not properly supported till elastic#80926.
Previously the created token always has no previlege. Now the token has
the same privilege as the API key itself (similar to user created
tokens). Authenticating using the token is considered equivalent to the
API key itself. Therefore the "isApiKey" check needs to be updated to
cater for both authentications of API key itself and the token created
by the API key.

This PR updates the isApiKey check and apply it consistently to ensure
the behaviour is consistent between an API key and a token created by
it.

The only exception is for supporting run-as. API key itself can run-as
another user. But a token created by the API key cannot perform run-as
(elastic#84336) similar to how user/token works.
elasticsearchmachine pushed a commit that referenced this pull request Feb 28, 2022
Creating tokens using API keys is not properly supported till #80926.
Previously the created token always has no previlege. Now the token has
the same privilege as the API key itself (similar to user created
tokens). Authenticating using the token is considered equivalent to the
API key itself. Therefore the "isApiKey" check needs to be updated to
cater for both authentications of API key itself and the token created
by the API key.

This PR updates the isApiKey check and apply it consistently to ensure
the behaviour is consistent between an API key and a token created by
it.

The only exception is for supporting run-as. API key itself can run-as
another user. But a token created by the API key cannot perform run-as
(#84336) similar to how user/token works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) Team:Security Meta label for security team v8.1.0 v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants