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

Make sure aud from SDS JWT is Citadel #16666

Merged
merged 4 commits into from
Aug 30, 2019

Conversation

pitlv2109
Copy link
Member

@pitlv2109 pitlv2109 commented Aug 29, 2019

Please provide a description for what this PR is for.
#16637

And to help us figure out who should review this PR, please
put an X in all the areas that this PR affects.

[ ] Configuration Infrastructure
[ ] Docs
[X] Installation
[ ] Networking
[ ] Performance and Scalability
[ ] Policies and Telemetry
[X] Security
[ ] Test and Release
[ ] User Experience
[ ] Developer Infrastructure

@istio-testing istio-testing added the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Aug 29, 2019
@googlebot googlebot added the cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. label Aug 29, 2019
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 29, 2019
@myidpt myidpt added this to the 1.3 milestone Aug 29, 2019
Copy link
Contributor

@myidpt myidpt left a comment

Choose a reason for hiding this comment

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

/lgtm
Please test with both valid and invalid audiences. Thanks :)

@myidpt myidpt requested a review from howardjohn August 29, 2019 18:19
@pitlv2109 pitlv2109 marked this pull request as ready for review August 29, 2019 19:26
@istio-testing istio-testing removed the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Aug 29, 2019
@pitlv2109
Copy link
Member Author

@howardjohn Could you take a quick look. Trying to get this in before Friday noon for the rc-1.

@@ -296,7 +296,7 @@ spec:
- serviceAccountToken:
path: istio-token
expirationSeconds: 43200
audience: {{ $.Values.global.trustDomain }}
audience: {{ $.Values.global.sds.token.aud }}
Copy link
Member

Choose a reason for hiding this comment

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

this is a backwards incompatible change it seems?

Copy link
Member Author

@pitlv2109 pitlv2109 Aug 29, 2019

Choose a reason for hiding this comment

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

hmm there shouldn't be any problem, but regardless of this, sds is an alpha feature and not many people are using it seriously

Copy link
Contributor

Choose a reason for hiding this comment

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

And it's clear that trustDomain is not the real audience of this token, but the CA service that provides the certificates.

// If the audiences are not specified, the api server will use the audience of api server,
// which is also the issuer of the jwt.
// This feature is only available on Kubernetes v1.13 and above.
Audiences: []string{defaultAudience},
Copy link
Member

Choose a reason for hiding this comment

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

when is this ever overrided? Seems like default is always used?

Copy link
Member Author

Choose a reason for hiding this comment

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

For 1.3, it's hard-coded. We will revisit it post 1.3 (maybe a patch in 1.3.x) to support configurable trust domain. The audience should be Citadel. We won't support Vault with trustworthy JWT for now

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok to have it hard-coded - but hard-code it in the template as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

And I don't think it matters if Vault or something else is used - as long as they check the same constant for audience it'll probably work.

The intent of audience is to make sure a server doesn't accept a token intended for a different server.

I'm not entirely sure the spifee URL is a proper use for audience - it's intended to identify workloads, not audiences. You could have any SA or workload implementing the cert signing service.

Maybe a simple string "istio-ca" as hardcoded audience would be better ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@myidpt wdyt? I'm okay with either option (istio-ca or the spiffee one)

Copy link
Contributor

@myidpt myidpt Aug 29, 2019

Choose a reason for hiding this comment

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

I'm OK with "istio-ca" since it's hard-coded anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated the PR to use "istio-ca". PTAL

Copy link
Member

Choose a reason for hiding this comment

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

why not hard code in the template then?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not always "istio-ca". For example, for GoogleCA, this value is different and Istio cannot control it

@howardjohn
Copy link
Member

@costinm recommend you look at SDS values changes

Copy link
Contributor

@costinm costinm left a comment

Choose a reason for hiding this comment

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

The default audience seems to be hardcoded - so I don't think we need to add more config UX.

The agreement is that new runtime configs will go to istio/api and reviewed as API - I suggest just using the same hardcoded version - since obviously setting it to any other value will fail the check in citadel, so we're adding a setting that can't be changed by user.

@costinm
Copy link
Contributor

costinm commented Aug 29, 2019

I mean - there is no need to go trough istio/api review since this is not a setting that we need - but a constant that doesn't need to be exposed to the user.

@pitlv2109
Copy link
Member Author

I mean - there is no need to go trough istio/api review since this is not a setting that we need - but a constant that doesn't need to be exposed to the user.

Just to be clear, the aud needs to be configurable in Helm because different CAs expect different value for the aud. In GoogleCA, it's the trust domain. In Citadel, I'm not sure if it makes sense to set it to "cluster.local" @myidpt

@pitlv2109
Copy link
Member Author

@pitlv2109 It's a good practice to document the defaults. Setting the default value istio-ca in values.yaml would achieve that, right?

Well the default is not to use sds, so it should be empty. Same with some other sds attributes.

If I run helm template I will get token.aud=""

Isn't this intended? You'll also get sds.udsPath="", because by default sds is not enabled, and its attributes should be empty. If they want to enable sds, they will pass the sds yaml file. This is what we're using and recommending the users now. Why change the structure? If there is a strong reason that we need to move all default values to values.yaml (which I don't see why, unless the new installer really needs it this way), then this work deserves another PR to change the structure of the whole thing.

@rlenglet
Copy link
Contributor

Well the default is not to use sds, so it should be empty. Same with some other sds attributes.

Does it harm to leave it non-empty?

@rlenglet
Copy link
Contributor

The important point for a default value is that it always works. istio-ca always works, right?

@rlenglet
Copy link
Contributor

If they want to enable sds, they will pass the sds yaml file.

That's a good point.

@howardjohn
Copy link
Member

What other feature requests the user to pass a full new values-sds.yaml file? You shouldn't need to set 20 values in order to use a feature.

There is no reason a user should ever care about token.aud unless the are using GoogleCA, so they should never have to configure it.

Then you can remove it from values-istio-sds-auth.yaml, and all the other 'profiles'

Co-Authored-By: John Howard <howardjohn@google.com>
@howardjohn
Copy link
Member

Opened #16705 to track making SDS easier to enable

@rlenglet
Copy link
Contributor

I filed #16706 so we can track the issue of SDS default values later.

@rlenglet
Copy link
Contributor

Opened #16705 to track making SDS easier to enable

@howardjohn beat me to it. ;)

@pitlv2109
Copy link
Member Author

What other feature requests the user to pass a full new values-sds.yaml file? You shouldn't need to set 20 values in order to use a feature.

Well the users do not need to set it, they only need to pass in the sds yaml file. Whether this modular model is good, that's another discussion.

There is no reason a user should ever care about token.aud unless the are using GoogleCA, so they should never have to configure it.

So that we're on the same page, Istio users never have to configure this.

Copy link
Contributor

@rlenglet rlenglet left a comment

Choose a reason for hiding this comment

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

Thanks @pitlv2109!

@howardjohn
Copy link
Member

Passing --values sds.yaml or whatever is configuring it. Now with your change they don't. As mentioned in the issue I opened, ideally we would be able to just do helm install --set sds.enabled=true and things just work out of the box.

Thanks for making the change

@istio-testing
Copy link
Collaborator

In response to a cherrypick label: new pull request created: #16711

@@ -83,10 +89,10 @@ func (authn *K8sSvcAcctAuthn) reviewServiceAccountAtK8sAPIServer(targetToken str
Kind: "TokenReview",
Spec: specForSaValidationRequest{
Token: targetToken,
Copy link
Contributor

Choose a reason for hiding this comment

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

To confirm: for 1.12 we are still subject to 'confused deputy' ? My understanding was that we will check the audience in citadel ( by decoding the token and comparing ) so it works on 1.12 as well.

If in 1.12 audience check doesn't work and we don't add the fix - it should probably be in release notes, so users avoid using SDS ( or don't use any JWT tokens with any other servers that may create a 'confused deputy' problem)

Copy link
Contributor

Choose a reason for hiding this comment

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

If adding release notes, please do it here: https://github.com/istio/istio/wiki/Release-Note-1.3-Draft

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated the release notes.

Copy link
Member

Choose a reason for hiding this comment

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

Did we agree to completely break SDS for k8s 1.12 in TOC? My understanding is we just agreed to get rid of legacy jwt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we agreed to get rid of legacy jwt.

Copy link
Member Author

Choose a reason for hiding this comment

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

GKE now has 1.13.7, so I think it's fine to ask customers to use 1.13? Also, Istio claims to support 1.13-1.15 https://preliminary.istio.io/faq/general/#what-deployment-environment for 1.3.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, it's a breaking change. K8s below 1.13 fails to check if aud is anything other than api server.
Technically, we could still support 1.12 if in Citadel we parse the jwt and check if the audience is istio-ca, and send the TokenReview without the audience. I think you suggested this but I thought just bump the support to 1.13 and let k8s api does all the work.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm happy to let Citadel does the dirty work so that we can support k8s 1.12 or encourage users to upgrade to a newer k8s verion for other benefits, including security, that k8s > 1.12 offers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I didn't know this is a breaking change to 1.12. Given that SDS is an Alpha feature, I think it's acceptable to ask users to upgrade to 1.13 to use SDS (Also technically this doesn't break our policy of supporting the latest 3 K8s versions). We will update the release notes, blog post and the SDS task.

Having Citadel to check the audience isn't nice IMO. If we decide to check the audience in Citadel, we must not check it on apiserver.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, so I'll keep things as they are. I've updated all the relevant docs.

@howardjohn
Copy link
Member

howardjohn commented Aug 30, 2019 via email

@howardjohn
Copy link
Member

howardjohn commented Aug 30, 2019 via email

howardjohn added a commit to howardjohn/test-infra that referenced this pull request Sep 2, 2019
Support for this version has both been dropped and broken by
istio/istio#16666. We can re-enable this if we
get back support for 1.12 (note - this is not officially supported
version, so low priority) or disable just the test that is broken.
istio-testing pushed a commit to istio/test-infra that referenced this pull request Sep 3, 2019
Support for this version has both been dropped and broken by
istio/istio#16666. We can re-enable this if we
get back support for 1.12 (note - this is not officially supported
version, so low priority) or disable just the test that is broken.
howardjohn added a commit to howardjohn/istio that referenced this pull request Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants