ingress-nginx icon indicating copy to clipboard operation
ingress-nginx copied to clipboard

TCP Proxy: Fix TLS passthrough for fragmented ClientHello.

Open maxl99 opened this issue 1 year ago • 9 comments

What this PR does / why we need it:

We need to read the entire length of the ClientHello packet in order to get the SNI field for proper tls passthrough.

Types of changes

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] CVE Report (Scanner found CVE and adding report)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Documentation only

Which issue/s this PR fixes

fixes #11491 fixes #11424

How Has This Been Tested?

Tested with tldr_fail_test.py (modified to use tls1.2) Without the patch: image With the patch, passthrough also works for a fragmented ClientHello.

Checklist:

  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I've read the CONTRIBUTION guide
  • [ ] I have added unit and/or e2e tests to cover my changes.
  • [x] All new and existing tests passed.

maxl99 avatar Aug 21 '24 10:08 maxl99

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 avatar Aug 21 '24 10:08 k8s-ci-robot

Welcome @maxl99!

It looks like this is your first PR to kubernetes/ingress-nginx 🎉. 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/ingress-nginx 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. :smiley:

k8s-ci-robot avatar Aug 21 '24 10:08 k8s-ci-robot

Hi @maxl99. 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 avatar Aug 21 '24 10:08 k8s-ci-robot

Deploy Preview for kubernetes-ingress-nginx canceled.

Name Link
Latest commit 79dbfba4d42dc4675b407f3cd42f69b4a47d95f2
Latest deploy log https://app.netlify.com/sites/kubernetes-ingress-nginx/deploys/673527a37915930008193d98

netlify[bot] avatar Aug 21 '24 10:08 netlify[bot]

/ok-to-test

I will run the test suite first.

tao12345666333 avatar Oct 12 '24 07:10 tao12345666333

/kind bug /priority backlog /hold

If this is a bug, could you please also add some tests to prevent future regression?

Gacko avatar Oct 12 '24 13:10 Gacko

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kvaps, maxl99 Once this PR has been reviewed and has the lgtm label, please ask for approval from tao12345666333. For more information see the Kubernetes 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

k8s-ci-robot avatar Oct 17 '24 10:10 k8s-ci-robot

/kind bug /priority backlog /hold

If this is a bug, could you please also add some tests to prevent future regression?

I tried to implement an e2e test that sends a ClientHello with 2 packets (similar to the behaviour we see in the packet capture). Sadly it seems to be a bit tricky because the test is also successful without the patch :( I'm using net.Dial and Write. I also tried casting it to an net.TCPConn and setting things like SetWriteBuffer(0) and SetNoDelay(true).

maxl99 avatar Oct 17 '24 10:10 maxl99

ssl-passthrough is targeted for deprecation.

I understand this is disruptive. But there is demand for real-client-ip and now this fragmented client-helo. Its also very clear that 2 PRs are in queue for addressing this.

But please consider that the requirement now is 2 folds. On one hand a developer of the project needs to evaluate not just the PRs here but also the impact of those changes on the design, security & stability of the controller.. Secondly the continued support/maintenance to sustain the TLS-Passthrough feature in its current go-proxy avatar, requires resources.

The project hit CVEs and and other sustaining related problems and faced acute shortage of resources for a extended length of time. So to avoid future impact to the security/stability of the controller, a decision was made to focus on the core functionality of the project. We are even deprecating several functioning useful popular features. Implementing the Gateway-API is the other focus besides shipping a secure-by-default controller.

Hence wait for other comments, but I would say not to expect much traction on this as the TLS-Passthrough feature itself may be deprecated sooner than later. I understand its the least desired scene but its the reality of changing times.

Users do obviously have the option to fork the project and implement desired changes there. regards.

longwuyuan avatar Oct 22 '24 07:10 longwuyuan