Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix overlapping client CA and requestheader CA validation with proper certificate checking #131411

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
Loading
from

Conversation

ballista01
Copy link
Contributor

@ballista01 ballista01 commented Apr 23, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR introduces a validation check at server startup for the Kubernetes API server configuration. It ensures that when --client-ca-file and --requestheader-client-ca-file refer to CA bundles that share any certificate, and --requestheader-allowed-names is not set, then the API server will abort startup with an error.

This closes a privilege escalation risk where any client with a certificate issued by the shared CA can spoof identities via the request header authentication approach, based on Kubernetes Security Audit Finding NCC-E003660-F9W.

Which issue(s) this PR fixes:

Fixes #119267

Special notes for your reviewer:

  • Certificate overlap detection uses client-go/util/cert.CertsFromFile() and x509.Certificate.Equal().
  • Newly added test CA files are from staging/src/k8s.io/kube-aggregator/pkg/apiserver/testdata
  • It's a continuation of PR#123008

Does this PR introduce a user-facing change?

kube-apiserver: when --requestheader-client-ca-file and --client-ca-file contain overlapping certificates, --requestheader-allowed-names must be specified to ensure regular client certificates cannot set authenticating proxy headers for arbitrary users

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 23, 2025
@k8s-ci-robot
Copy link
Contributor

Please note that we're already in Test Freeze for the release-1.33 branch. This means every merged PR will be automatically fast-forwarded via the periodic ci-fast-forward job to the release branch of the upcoming v1.33.0 release.

Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Wed Apr 23 01:34:47 UTC 2025.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 23, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @ballista01. 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 needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 23, 2025
@k8s-ci-robot k8s-ci-robot requested review from cheftako and jpbetz April 23, 2025 02:21
@ballista01
Copy link
Contributor Author

/sig security

@k8s-ci-robot k8s-ci-robot added the sig/security Categorizes an issue or PR as relevant to SIG Security. label Apr 23, 2025
@ballista01
Copy link
Contributor Author

/remove-sig api-machinery

@k8s-ci-robot k8s-ci-robot removed the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Apr 23, 2025
@pacoxu
Copy link
Member

pacoxu commented Apr 28, 2025

/ok-to-test
/sig auth

@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. sig/auth Categorizes an issue or PR as relevant to SIG Auth. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 28, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Auth Apr 28, 2025
@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Apr 28, 2025
@BenTheElder
Copy link
Member

#119267 (comment)
/assign @liggitt

@siyuanfoundation
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Apr 29, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Apr 29, 2025
Copy link
Member

@liggitt liggitt left a comment

Choose a reason for hiding this comment

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

one suggestion on the error message, and squash to a single commit, then lgtm

pkg/kubeapiserver/options/authentication.go Outdated Show resolved Hide resolved
@liggitt liggitt removed request for jpbetz and cheftako April 30, 2025 04:18
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ballista01
Once this PR has been reviewed and has the lgtm label, please ask for approval from liggitt. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@ballista01 ballista01 force-pushed the apiserver-requestheader-security-fix branch 2 times, most recently from e38e237 to 84488c9 Compare May 1, 2025 05:26
@ballista01
Copy link
Contributor Author

/retest

@@ -55,8 +56,12 @@ import (
)

func TestAuthenticationValidate(t *testing.T) {
testDataDir := filepath.Join("testdata")
Copy link
Member

Choose a reason for hiding this comment

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

You can remove this variable and use "testdata" directly below. Linting is complaining about this bit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!

… certificate checking

fix error message

fix lint
@ballista01 ballista01 force-pushed the apiserver-requestheader-security-fix branch from 84488c9 to 03357ed Compare May 2, 2025 04:14
@aramase aramase moved this from Needs Triage to In Review in SIG Auth May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/auth Categorizes an issue or PR as relevant to SIG Auth. 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. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

NCC-E003660-F9W: Common Certificate Authority Possible for Client CA and Request
6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.