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

Remove use of REDACTED in config output for public CA #61573

Closed
sethvargo opened this issue Mar 23, 2018 · 23 comments · Fixed by #66023
Closed

Remove use of REDACTED in config output for public CA #61573

sethvargo opened this issue Mar 23, 2018 · 23 comments · Fixed by #66023
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@sethvargo
Copy link

sethvargo commented Mar 23, 2018

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:

kubectl config view shows:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
# ...

The use of "REDACTED" for a CA here is misleading, since it's a public certificate that is not a secret.

What you expected to happen:

I expected to see the full CA in pem format (like when you cat ~/.kube/config) or something like "SUPPRESSED" or "TRUNCATED"

How to reproduce it (as minimally and precisely as possible):

  1. Run kubectl config view

Anything else we need to know?:

Nope

Environment:

  • Kubernetes version (use kubectl version):

    Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.6", GitCommit:"9f8ebd171479bec0ada837d7ee641dec2f8c6dd1", GitTreeState:"clean", BuildDate:"2018-03-21T20:49:12Z", GoVersion:"go1.9.4", Compiler:"gc", Platform:"darwin/amd64"}
    Server Version: version.Info{Major:"1", Minor:"8+", GitVersion:"v1.8.8-gke.0", 
    GitCommit:"6e5b33a290a99c067003632e0fd6be0ead48b233", GitTreeState:"clean", 
    BuildDate:"2018-02-16T18:26:58Z", GoVersion:"go1.8.3b4", Compiler:"gc", Platform:"linux/amd64"}
    
  • Cloud provider or hardware configuration:

    GKE, but applies to CLI
    
  • OS (e.g. from /etc/os-release):

    Mac OS X
    
  • Kernel (e.g. uname -a):

    Darwin X 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
    
@k8s-ci-robot k8s-ci-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Mar 23, 2018
@sethvargo
Copy link
Author

sethvargo commented Mar 23, 2018

@kubernetes/sig-cli-bugs @kubernetes/sig-auth-bugs (for thoughts)

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. kind/bug Categorizes issue or PR as related to a bug. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 23, 2018
@k8s-ci-robot
Copy link
Contributor

@sethvargo: Reiterating the mentions to trigger a notification:
@kubernetes/sig-cli-bugs

In response to this:

@kubernetes/sig-cli-bugs @kubernetes/sig-security-bugs (for thoughts)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@zjj2wry
Copy link
Contributor

zjj2wry commented Mar 23, 2018

@sethvargo use kubectl config view --raw you can see the complete certificate authority data

@sethvargo
Copy link
Author

Hey @zjj2wry

Thank you - I have another issue tracking that 😄.

The point of this issue is that at best it's a bad UX; at worst it's a miseducation on pki. "REDACTED" isn't the right word here

@zjj2wry
Copy link
Contributor

zjj2wry commented Mar 23, 2018

@sethvargo If there are multiple clusters displaying certificates, the configuration will be too long, so this switch is turned off by default. But we can add an example to help use. thanks

@sethvargo
Copy link
Author

Hey @zjj2wry

I don't personally view truncation the responsibility of the CLI... users can pipe things to a pager if they really care. That being said, I'm not concerned about the length. The issue is purely about the word choice of "REDACTED".

The term redact means:

censor or obscure (part of a text) for legal or security purposes.

The use of the term "REDACTED" in the output implies that a CA public key is remove for security when (as you've pointed out) it is removed for truncation. Truncation and redaction are fundamentally different things, and k8s is misusing the word redacted for this use case.

@cblecker
Copy link
Member

Not quite a bug, but I think you're right @sethvargo a better term could be used there as it is a public key, not a private key.

@kubernetes/sig-auth-feature-requests
/remove-kind bug

@k8s-ci-robot k8s-ci-robot added sig/auth Categorizes an issue or PR as relevant to SIG Auth. kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Mar 23, 2018
@liggitt liggitt removed the sig/auth Categorizes an issue or PR as relevant to SIG Auth. label Mar 28, 2018
k8s-github-robot pushed a commit that referenced this issue Mar 29, 2018
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

add kubectl config view --raw example help user use

**What this PR does / why we need it**:
ref #61573

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:


**Special notes for your reviewer**:
cc @liggitt @soltysh @juanvallejo 
**Release note**:

```release-note
NONE
```
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 26, 2018
@sethvargo
Copy link
Author

/remove-lifecycle stale

I'm not sure what I need to do here. This was marked as a feature. Do you need something more from me?

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 27, 2018
@mikedanese mikedanese added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels Jun 27, 2018
@mikedanese
Copy link
Member

We are waiting for someone to fix this.

@cblecker
Copy link
Member

/remove-good-first-issue

@mikedanese I don't think this fits our definition of a good first issue: https://git.k8s.io/community/contributors/devel/help-wanted.md#good-first-issue

@k8s-ci-robot k8s-ci-robot removed the good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. label Jun 27, 2018
@sethvargo
Copy link
Author

So I have to keep replying to the comment bot every 30 days so it doesn't get auto-closed? That feels... odd

@mikedanese
Copy link
Member

@cblecker thanks for the education :)

@sethvargo unfortunately other issues are higher priority and no one has stepped up to fix this. The autocloser is a form of bug bankruptcy that keeps our issue load in check. The contribex special interest group is definitely open to feedback on the bot.

@ibrasho
Copy link
Contributor

ibrasho commented Jul 8, 2018

@sethvargo The biggest hurdle in this is that Kubernetes is using some base64 trickery to display the string REDACTED (basically setting the certificate data to the decoded bytes from REDACTED).

We can change this to TRUNCATE or TRUNCATEDCRT but not TRUNCATED (it has to be a valid base64 encoded string). I tried exploring multiple options for the text, but I couldn't find a suitable one.

Given that we already print the user tokens and other credentials this is a bit weird. Should we redact those too? Is it okay if we print the CA certificate instead of truncating it?

@sethvargo
Copy link
Author

@ibrasho I can't help but laugh at:

but not TRUNCATED (it has to be a valid base64 encoded string)

I'm not wed to any particular name. I also have no problem displaying the entire certificate. The crux of the issue is that a CA public key is not secret or sensitive. It's a public key 😄

@ibrasho
Copy link
Contributor

ibrasho commented Jul 9, 2018

I agree. The issue is with the constraints imposed by how this is implemented currently.

I tried to come up with a suitable string (given the constraint) and couldn't find anything acceptable... The only suitable option that worked for me is +DATA+TRUNCATED+. 😂

I personally prefer to print the CA certificate since we are already printing user tokens and client certs that are actual secrets.

@sethvargo
Copy link
Author

I agree. Who do we need to get in agreement that printing the full CA is the best path forward?

@liggitt
Copy link
Member

liggitt commented Jul 9, 2018

the data is not omitted for security purposes, but to make the output more readable. see #7007

REDACTED is misleading... it should probably be "elided" or "..."

@liggitt
Copy link
Member

liggitt commented Jul 9, 2018

you can run kubectl config view --raw to view full content

@sethvargo
Copy link
Author

@liggitt that's the crux of this issue - REDACTED is misleading. However, @ibrasho pointed out that other "long" fields are still completely printed in plain text such as client certs, so I think we need to revisit the "readability" argument. What do you think?

@liggitt
Copy link
Member

liggitt commented Jul 9, 2018

other "long" fields are still completely printed in plain text such as client certs

they are not... client cert/key are elided in the same way for the same reason:

if len(authInfo.ClientKeyData) > 0 {
authInfo.ClientKeyData = redactedBytes
}
if len(authInfo.ClientCertificateData) > 0 {
authInfo.ClientCertificateData = redactedBytes
}

$ kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: REDACTED
    server: https://localhost:6443/
  name: local-up-cluster
contexts:
- context:
    cluster: local-up-cluster
    user: local-up-cluster
  name: local-up-cluster
current-context: local-up-cluster
kind: Config
preferences: {}
users:
- name: local-up-cluster
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED

something like "++data+omitted++" could be better

I think we need to revisit the "readability" argument. What do you think?

If the intent of config view without --raw specified is to be readable (which it currently is), printing many extremely long fields isn't great

@sethvargo
Copy link
Author

sethvargo commented Jul 9, 2018

Hmm what about:

cluster.CertificateAuthorityData[0:8] + " (TRUNCATED)"

I'm pretty sure that would give us a valid b64 string (8+12=20%4=0) and it would subtly hint that the data isn't a secret.

@ibrasho
Copy link
Contributor

ibrasho commented Jul 10, 2018

Only valid characters are A-Za-z0-9+/=. And adding a prefix from the certificate only complicates things.

DATA+OMITTED is a suitable usable option. I'll submit a PR to continue the discussion there.

k8s-github-robot pushed a commit that referenced this issue Aug 18, 2018
Automatic merge from submit-queue (batch tested with PRs 60790, 66023, 67549). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

change TRUNCATED to DATA+OMITTED in kubectl config view

**What this PR does / why we need it**:
Based on the discussion in #61573, this PR switches the replacement text for CA certificate data and client certificates and secrets printed using `kubectl config view`. Currently, `REDACTED` is used, which might give a false impression that the data is a secret (which is not true for the public certificates).

This PR changes `REDACTED` to `DATA+OMITTED`. The printed string is the base64 encoded string on the byte stream. Some trickery is involved to print a readable string (refer to [this comment](https://github.com/kubernetes/kubernetes/pull/66023/files#diff-aec000ca3f293c94dcd99b4a9d1c5c3cL86) for more info).

**Which issue(s) this PR fixes**:
Fixes #61573

**Special notes for your reviewer**:


**Release note**:
```release-note
Switched certificate data replacement from "REDACTED" to "DATA+OMITTED"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants