Skip to content

Conversation

@pmengelbert
Copy link
Contributor

@pmengelbert pmengelbert commented Aug 13, 2025

  • One-line PR description: Update kuberc KEP with credential plugin allowlist
  • Other comments:

Currently, the kubeconfig may specify arbitrary binaries to run as
client-go credential plugins. Due to the fact that kubeconfig files are
often generated, and because they contain a lot of noise, there is
significant friction in manually inspecting the kubeconfig for
suspicious binaries after it is generated.

To encourage secure behavior, we want to introduce an allowlist to the
kuberc, which will describe the conditions under which a binary plugin
may be run. Currently the only condition is the name (absolute path or
basename of a binary found in PATH).

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 13, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: pmengelbert / name: Peter Engelbert (536c62b)

@k8s-ci-robot k8s-ci-robot requested a review from ardaguclu August 13, 2025 21:06
@k8s-ci-robot k8s-ci-robot added the kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory label Aug 13, 2025
@k8s-ci-robot k8s-ci-robot requested a review from soltysh August 13, 2025 21:06
@k8s-ci-robot k8s-ci-robot added the sig/cli Categorizes an issue or PR as relevant to SIG CLI. label Aug 13, 2025
@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 13, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @pmengelbert!

It looks like this is your first PR to kubernetes/enhancements 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/enhancements has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 13, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG CLI Aug 13, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @pmengelbert. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 13, 2025
@enj
Copy link
Member

enj commented Aug 14, 2025

/sig auth

@k8s-ci-robot k8s-ci-robot added the sig/auth Categorizes an issue or PR as relevant to SIG Auth. label Aug 14, 2025
@enj
Copy link
Member

enj commented Aug 14, 2025

This LGTM from a SIG Auth perspective (I added us as a participating SIG).

@enj
Copy link
Member

enj commented Aug 14, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 14, 2025
@enj enj added this to SIG Auth Aug 15, 2025
@enj enj moved this to Needs Triage in SIG Auth Aug 15, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 19, 2025
@ibihim ibihim moved this from Needs Triage to In Review in SIG Auth Aug 25, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Sep 2, 2025
Copy link
Member

@ardaguclu ardaguclu left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. I'll defer the final approval from SIG-CLI POV to @soltysh

reason. The user should instead use `credentialPluginPolicy: DisableAll` in
this case.

Commands that don't create a client, such as `kubectl config view` will not be
Copy link
Member

Choose a reason for hiding this comment

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

is there any other command that will be exceptional like kubectl config view?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Off the top of my head, there are
kubectl config (any subcommand)
kubectl version
kubectl plugin list

Should I update the KEP with a full list?

Copy link
Member

Choose a reason for hiding this comment

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

hmm... I think it's going to be hard to enumerate every specific command that won't actually use the client. There's lots of commands that only run locally with specific options (e.g. all kubectl create ... --dry-run=client commands, or kubectl {label,annotate,set} --local)

I think the implementation should be structured so that it intercepts attempts to use a non-allowlisted credential plugin and rejects them at time of use, so commands that don't even need the plugin don't start failing for no reason.

Copy link
Member

@ardaguclu ardaguclu Sep 9, 2025

Choose a reason for hiding this comment

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

I think the implementation should be structured so that it intercepts attempts to use a non-allowlisted credential plugin and rejects them at time of use, so commands that don't even need the plugin don't start failing for no reason.

So that significantly changes the implementation. Maybe we just need to get the list of plugins (allowed, disallowed, etc.) in kubectl/cmd and pass it to client-go (or cli-runtime) to accept/reject this credential exec plugin, when there is a request to API Server?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this will change the implementation that much. Per my understanding, that was how it was going to work from start.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the implementation should be structured so that it intercepts attempts to use a non-allowlisted credential plugin and rejects them at time of use, so commands that don't even need the plugin don't start failing for no reason.

So that significantly changes the implementation. Maybe we just need to get the list of plugins (allowed, disallowed, etc.) in kubectl/cmd and pass it to client-go (or cli-runtime) to accept/reject this credential exec plugin, when there is a request to API Server?

Per recent discussion in the sig-api-machinery biweekly, they are in agreement with the following:

  1. The allowlist can be specified in kuberc as described by this KEP so that kubectl may benefit from it.
  2. The allowlist will be parsed by the kuberc parser.
  3. The allowlist parsing logic should be made public if it is not already, such that non-kubectl clients can use it to read allowlists configured there.
  4. client-go will be modified to permit a hook accepting a parsed allowlist on client creation.
  5. Frontends other than kubectl may use this hook to use the allowlist
  6. Go clients can use the hook as they wish
  7. The allowlist will be plumbed to the point of plugin execution and will be consulted before the exec call.

Copy link
Member

@ardaguclu ardaguclu Oct 6, 2025

Choose a reason for hiding this comment

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

That sounds like a reasonable plan to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

This all sounds exactly what I was imagining it would, thank you!

@ardaguclu
Copy link
Member

ardaguclu commented Sep 5, 2025

I think, this PR needs a rebase to remove the invalid-commit label. Otherwise, this PR can't be merged.

@pmengelbert pmengelbert force-pushed the pmengelbert/sig-cli/kuberc/4 branch 2 times, most recently from 7e85530 to 23506b7 Compare September 8, 2025 18:11
@pmengelbert
Copy link
Contributor Author

go ahead and squash down commits and take out the @mention in the commit message tripping up the presubmit check

@liggitt done

@pmengelbert
Copy link
Contributor Author

pmengelbert commented Oct 7, 2025

The threat is from downloaded kubeconfigs. A user implicitly trusts the tools (ex the aws, az, etc cli tools, or kind) that generate kubeconfigs -- if they are malicious then there is already a malicious process running on the user's system and the kuberc configuration shouldn't be expected to protect the user.

I'm not sure what this use case looks like TBH, I have only ever locally generated with eg gcloud, kind, minikube, eksctl, ...

An example: a CI pipeline creates a cluster on-demand and generates a kubeconfig using bespoke tools. That generated kubeconfig is produced as an artifact for a cluster user to download. Now the bespoke tooling and the pipeline are targets because they generate a kubeconfig; the allowlist protects the user of that kubeconfig from compromised pipelines or tooling.

I think we should be clear about how we expect it to be used safely though.

Agreed, I will add language clarifying this.

Maybe SIG Security folks can take a look.

/sig security
(Does that work?)

@k8s-ci-robot k8s-ci-robot added the sig/security Categorizes an issue or PR as relevant to SIG Security. label Oct 7, 2025
@pmengelbert pmengelbert force-pushed the pmengelbert/sig-cli/kuberc/4 branch 2 times, most recently from c306ddc to 9a6f723 Compare October 7, 2025 19:45
Currently, the kubeconfig may specify arbitrary binaries to run as
client-go credential plugins. Due to the fact that kubeconfig files are
often generated, and because they contain a lot of noise, there is
significant friction in manually inspecting the kubeconfig for
suspicious binaries after it is generated.

To encourage secure behavior, we want to introduce an allowlist to the
kuberc, which will describe the conditions under which a binary plugin
may be run. Currently the only condition is the name (absolute path or
basename of a binary found in `PATH`).

* Revise based on feedback
  - Describe behavior when allowlist is `nil`
  - Describe behavior when allowlist is empty
  - Describe future plans for field additions
* Add SIG Auth as participating SIG
* Update TOC for KEP 3104
* Correct `os.LookPath` to `exec.LookPath`
* Add note about when the allowlist will not apply
* Avoid confusion between nil list and empty list
    In the credential plugin allowlist, consider nil and empty lists an
    error. Jordan Liggitt has pointed out that treating them differently is
    generally avoided in APIs, as it can confuse users.
    In order to make the user's intention more explicit, an additional
    field, `credentialPluginPolicy` has been added. Its value must be one of
    `EnableAll | DisableAll | Allowlist`. `EnableAll` and `DisableAll` are
    self-explanatory and do not require an allowlist. `Allowlist` will use
    the allowlist as defined in the KEP.
* Note that this change considers the following cases to be errors:
  - a policy of `EnableAll` with an allowlist provided
  - a policy of `DisableAll` with an allowlist provided
  - a policy of `Allowlist` with no allowlist provided (i.e. a `nil`
  - allowlist`
  - a policy of `Allowlist` with an explicitly empty allowlist provided
* Clarify v1beta1 and kubectl v1.35 only (allowlist)
* Update kep.yaml
  - Add sig-api-machinery as participating SIG
  - Add enj as reviewer
  - Update latest milestone to v1.35
* Allowlist: rename `name` field to `command`
* Clarify meaning of "the operation will fail"
* Specify appropriate api group and version
* Move detail to new section under `Design Details`
* Add table showing `command` comparison

Signed-off-by: Peter Engelbert <[email protected]>
@pmengelbert pmengelbert force-pushed the pmengelbert/sig-cli/kuberc/4 branch from 9a6f723 to 536c62b Compare October 7, 2025 19:57
@pmengelbert
Copy link
Contributor Author

All comments have been addressed and this is ready for another round of review.

@liggitt
Copy link
Member

liggitt commented Oct 7, 2025

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 7, 2025
@pmengelbert
Copy link
Contributor Author

/assign mpuckett159
pinging @mpuckett159 for review

Not sure if I should wait until there's a review from someone in sig-cli-leads to request your review, but given the looming enhancements freeze I figured better safe than sorry.

@ardaguclu
Copy link
Member

I'm approving from sig-cli POV
/approve
I'm also adding hold to give a chance to @soltysh for one last check
/hold

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 8, 2025
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

I left there one comment we can discuss during implementation, not blocking this document, though.

/lgtm
/approve


If `credentialPluginPolicy` is set to `Allowlist`, but a
`credentialPluginAllowlist` is not provided, it will be considered an
configuration error. Rather than guess at what the user intended, the operation
Copy link
Contributor

Choose a reason for hiding this comment

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

Configuration error should error out during parsing not during execution. We already have a separate validation step which I'd expect to be extended with validation for this new addition.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, liggitt, pmengelbert, soltysh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@soltysh
Copy link
Contributor

soltysh commented Oct 9, 2025

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 9, 2025
@k8s-ci-robot k8s-ci-robot merged commit c3e5684 into kubernetes:master Oct 9, 2025
2 of 4 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.35 milestone Oct 9, 2025
@github-project-automation github-project-automation bot moved this from In Review to Closed / Done in SIG Auth Oct 9, 2025
@github-project-automation github-project-automation bot moved this from Needs Triage to Done in SIG CLI Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/security Categorizes an issue or PR as relevant to SIG Security. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

Status: API review completed, 1.35
Status: Closed / Done
Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants