Skip to content

BackendTLSPolicy SANs field marked as extended #3591

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

Merged

Conversation

mlavacca
Copy link
Member

@mlavacca mlavacca commented Feb 4, 2025

What type of PR is this?

What this PR does / why we need it:

Given the not triviality of supporting this feature for nginx-based implementations (such as Kong) and the fact that this feature is not mandatory to ensure core functionality in the proxy->backend encrypted communication, we can set the SANs field of the BackendTLSPolicy API as an extended feature.

/cc @robscott @shaneutt @youngnick @LiorLieberman @candita

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

The SANs field of `backendTLSPolicy` has been marked as an extended feature.

@k8s-ci-robot k8s-ci-robot requested a review from candita February 4, 2025 15:35
@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Feb 4, 2025
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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. kind/gep PRs related to Gateway Enhancement Proposal(GEP) size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 4, 2025
@howardjohn
Copy link
Contributor

My understanding is this is required to fully validate a certificate. So it seems rather insecure and defeating most benefits of TLS to not validate this, which doesn't seem great.

Am I missing something that makes this not essentially insecureSkipVerify (which, as the name implies, is not secure)?
I get it still validates the CA but that is not relevant - anyone can get a certificate

@howardjohn
Copy link
Contributor

Or is it specifically subject alt names that is the issue and CN (deprecated for like 20 years IIRC) is used?

@mlavacca
Copy link
Member Author

mlavacca commented Feb 4, 2025

The problem is the list of subjectAlternativeNames for which at least a match is required to validate the certificate. In the Kong proxy, it is possible to provide a single value (which by default for this API is the hostname).

In the proxy, the certificate is properly validated against the SANs field; what's missing is the possibility of setting multiple SANs in the proxy configuration to check the certificate against.

@howardjohn
Copy link
Contributor

Then can we make support for 1 core and support for more than 1 extended? I think we do that with gateway TLS certs

@howardjohn
Copy link
Contributor

I guess using Hostname for that is probably pretty close to that. But might be slightly more flexible to allow 1

@mlavacca
Copy link
Member Author

mlavacca commented Feb 4, 2025

I guess using Hostname for that is probably pretty close to that. But might be slightly more flexible to allow 1

How would it be more flexible? As you said, I don't see much difference compared to using Hostname for cert validation, except for complicating the interface and the validation.

Copy link
Contributor

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

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

SNI is not always the same as the certificate subject
for example it's quite common for a kube-apiserver to have IP SANs - those cannot be the SNI.

Or many other SANS exist like email, uri, etc

or I may go through a proxy routing on SNI but the TLS is terminated by another host

@mlavacca
Copy link
Member Author

mlavacca commented Feb 4, 2025

SNI is not always the same as the certificate subject for example it's quite common for a kube-apiserver to have IP SANs - those cannot be the SNI.

Or many other SANS exist like email, uri, etc

or I may go through a proxy routing on SNI but the TLS is terminated by another host

Agreed with all the above, which I honestly think we can consider more advanced use cases. Having just the hostname is not an insecure practice, as it boils down to assuming the certificate SAN to be the same as the SNI. All the valid scenarios you proposed are completely legit, but do they need to be treated as core and mandatory for an implementation?

@howardjohn
Copy link
Contributor

Yep I didn't make the full connection with Hostname in my initial comments. I think there's still an argument to be made on what exactly is core or not, but as long as "secure is core" then that works for me

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 14, 2025
Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
@mlavacca mlavacca force-pushed the backendtlspolicy-sans-extended branch from e14ddd5 to 3a44c4c Compare February 18, 2025 14:36
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2025
Co-authored-by: Shane Utt <shane@shaneutt.com>
Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

/approve

/cc @robscott @youngnick for lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mlavacca, shaneutt

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

@kubernetes-sigs kubernetes-sigs deleted a comment from k8s-ci-robot Feb 18, 2025
@shaneutt shaneutt requested a review from howardjohn February 18, 2025 14:49
@shaneutt shaneutt added this to the v1.3.0 milestone Feb 18, 2025
Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
@youngnick
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 19, 2025
@mlavacca
Copy link
Member Author

/unhold

@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 Feb 21, 2025
@k8s-ci-robot k8s-ci-robot merged commit b5095ed into kubernetes-sigs:main Feb 21, 2025
13 checks passed
EyalPazz pushed a commit to EyalPazz/gateway-api that referenced this pull request Feb 27, 2025
* BackendTLSPolicy SANs field marked as extended

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>

* Apply suggestions from code review

Co-authored-by: Shane Utt <shane@shaneutt.com>

* Address reviews' comments

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>

---------

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
Co-authored-by: Shane Utt <shane@shaneutt.com>
EyalPazz pushed a commit to EyalPazz/gateway-api that referenced this pull request Feb 27, 2025
* BackendTLSPolicy SANs field marked as extended

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>

* Apply suggestions from code review

Co-authored-by: Shane Utt <shane@shaneutt.com>

* Address reviews' comments

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>

---------

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
Co-authored-by: Shane Utt <shane@shaneutt.com>
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/gep PRs related to Gateway Enhancement Proposal(GEP) lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

5 participants