-
Notifications
You must be signed in to change notification settings - Fork 17
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
Ephemeral service account tokens for Vault #93
Ephemeral service account tokens for Vault #93
Conversation
ab886d2
to
3c73e8b
Compare
mountPath: /var/run/secrets/kubernetes.io/vault | ||
` | ||
|
||
const annotatedPodYAML = ` |
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.
3c73e8b
to
2284e94
Compare
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.
just one nitpick but other than that LGTM
serviceAccountName: secret-reader | ||
restartPolicy: Never | ||
containers: | ||
- name: app |
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.
think this should be print-env
to match the YAML above, but this shouldn't affect the test
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.
Yep good point, I'll change them to match (though I'll go with app in both cases, as that's what we like to use)
2284e94
to
5636407
Compare
Kubernetes service account tokens, by default, are not rotated. Our Vault authentication chain requires that Kubernetes pods send their tokens to the Vault server, outside of the Kubernetes cluster. If a token was to be compromised in that exchange, the attacker would be able to impersonate this Kubernetes service account indefinitely. This is a significant security risk. This commit changes our mutating webhook to mount service account credentials using the kubelet projected volume mounts API. This API uses the kubelet to inject ephemeral service account tokens that are rotated periodically into the containers. We can use these tokens to authenticate against Vault, instead of tokens that are never revoked. In addition, we can set an audience for the projected token to be something other than the Kubernetes API server. This would prevent any leaked tokens being used for anything other than authenticating with Vault. While we don't use this at present, as our Vault installation relies on using this token to reflect token review requests back to the API server, we may switch to this in future if we think the security benefit is compelling.
5636407
to
babfc14
Compare
This reverts commit e5396f8.
We now only apply the envconsul-injector webhook to namespaces with this label, so we must add it if we want our tests to work.
Kubernetes service account tokens, by default, are not rotated. Our
Vault authentication chain requires that Kubernetes pods send their
tokens to the Vault server, outside of the Kubernetes cluster.
If a token was to be compromised in that exchange, the attacker would be
able to impersonate this Kubernetes service account indefinitely. This
is a significant security risk.
This commit changes our mutating webhook to mount service account
credentials using the kubelet projected volume mounts API. This API uses
the kubelet to inject ephemeral service account tokens that are rotated
periodically into the containers. We can use these tokens to
authenticate against Vault, instead of tokens that are never revoked.
In addition, we can set an audience for the projected token to be
something other than the Kubernetes API server. This would prevent any
leaked tokens being used for anything other than authenticating with
Vault. While we don't use this at present, as our Vault installation
relies on using this token to reflect token review requests back to the
API server, we may switch to this in future if we think the security
benefit is compelling.