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

feat: Kubeconfig file should not be world or group readable by default #1114

Merged
merged 5 commits into from
May 27, 2021

Conversation

ishustava
Copy link
Contributor

@ishustava ishustava commented Nov 21, 2020

Description

Changes kubeconfig file permissions from 0644 to 0600 when write_kubeconfig is set to true. Kubeconfig file should not be world or group readable due to the sensitive information such as credentials it contains.

Checklist

@ishustava ishustava changed the title Kubeconfig file should not be world or group readable fix: kubeconfig file should not be world or group readable Nov 21, 2020
@ishustava ishustava changed the title fix: kubeconfig file should not be world or group readable fix: Kubeconfig file should not be world or group readable Nov 21, 2020
@barryib
Copy link
Member

barryib commented Dec 22, 2020

Thanks @ishustava for opening this PR. I don't think that there is creds in kubeconfig. We rely on aws-cli or aws-iam-authenticator to get dynamically temporary credentials.

BTW, I think your approach is very opinionated and will probably cause issue for other users. Instead of putting 0600, you can add new variable kubeconfig_ file_permission. This will let users define what they wants as permissions.

@ishustava
Copy link
Contributor Author

Hey @barryib, sorry for the late reply - still catching up with all the things after the holiday break. Thanks so much for the review!

I don't think that there is creds in kubeconfig. We rely on aws-cli or aws-iam-authenticator to get dynamically temporary credentials.

That's a good point. However, there should still be no reason for this file to be world- or group-readable, if we follow the principle of least privilege. Can you think of any use-cases when users would want a more wide permission?

I think your approach is very opinionated and will probably cause issue for other users. Instead of putting 0600, you can add new variable kubeconfig_ file_permission. This will let users define what they wants as permissions.

I don't think this approach is very opinionated.

The CLIs for the other two major cloud providers (Azure and Google) create kubeconfig with 0600 permissions. eksctl, recommended by AWS, similarly creates the kubeconfig file with 0600 permissions, even though it uses aws-iam-authenticator if it exists on your PATH.

Furthermore, Helm versions v3.3.3+ will print a warning if the file is world or group readable, saying that this is insecure.

Given that all other commonly used CLIs also use and recommend the 0600 permission, I think it makes sense to follow that same pattern.

@barryib
Copy link
Member

barryib commented Jan 28, 2021

@ishustava Good points. Thanks for your clarification.

We can set the default to 0600, but I think we should let users change that default if they want or need.

@ishustava
Copy link
Contributor Author

Hey @barryib

I've updated the PR as you suggested. Let me know if I missed anything.

Thanks again for taking a look!

@ishustava
Copy link
Contributor Author

Hey @barryib, any chance we could merge this?

@ishustava
Copy link
Contributor Author

Just a quick follow-up: are there any other changes I should make? Could we merge this PR?

variables.tf Outdated Show resolved Hide resolved
@barryib
Copy link
Member

barryib commented May 17, 2021

Just a quick follow-up: are there any other changes I should make? Could we merge this PR?

Sorry, I reviewed it months ago but I didn't send it 😢

@barryib barryib changed the title fix: Kubeconfig file should not be world or group readable feat: Kubeconfig file should not be world or group readable by default May 27, 2021
kubectl.tf Outdated Show resolved Hide resolved
@barryib barryib self-assigned this May 27, 2021
@barryib barryib merged commit 4a9fc3a into terraform-aws-modules:master May 27, 2021
@barryib
Copy link
Member

barryib commented May 27, 2021

Thanks @ishustava for your contribution.

@ishustava
Copy link
Contributor Author

Thanks so much @barryib for taking this on and addressing the comments. Apologies for not addressing them!

Really appreciate your help getting this merged 🙏

ArchiFleKs pushed a commit to ArchiFleKs/terraform-aws-eks that referenced this pull request Jun 1, 2021
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants