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

api: client tls session resumption #4293

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

guydc
Copy link
Contributor

@guydc guydc commented Sep 20, 2024

What type of PR is this?

What this PR does / why we need it:

Introduces an API for TLS session management:

  • Session Timeout
  • Resumption opt-out option for stateless and stateful methods
  • Allow users to configure a TLS session ticket encryption keys from k8s secrets

Envoy recommends rotating ticket encryption keys frequently. Multiple keys should be managed: a primary encryption key and one or more (previously rotated) decryption keys. Due to the complexity involved, Envoy-Gateway managed encryption keys are left out as future improvement.

Which issue(s) this PR fixes:
related #4268

@guydc guydc requested a review from a team as a code owner September 20, 2024 19:04
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.00%. Comparing base (6eefb28) to head (8c33695).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4293      +/-   ##
==========================================
+ Coverage   65.98%   66.00%   +0.02%     
==========================================
  Files         197      197              
  Lines       23964    23964              
==========================================
+ Hits        15813    15818       +5     
+ Misses       7025     7022       -3     
+ Partials     1126     1124       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -15,6 +15,20 @@ type ClientTLSSettings struct {
// +optional
ClientValidation *ClientValidationContext `json:"clientValidation,omitempty"`
TLSSettings `json:",inline"`

Copy link
Member

@zhaohuabing zhaohuabing Sep 23, 2024

Choose a reason for hiding this comment

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

Could we explain here what is the default strategy used by Envoy/EG - no TLS resumption, stateless TLS resumption, or Ssateful TLS resumption?

Copy link
Member

@zhaohuabing zhaohuabing Sep 23, 2024

Choose a reason for hiding this comment

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

Could we add an intermediate layer SessionResumption here to group all the session-related parameters? This approach looks more intuitive to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a list of "typed" resumption settings and included docs explaining the default EG behavior.

// https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/transport_sockets/tls/v3/common.proto#extensions-transport-sockets-tls-v3-tlssessionticketkeys
// +kubebuilder:validation:MaxItems=16
// +optional
SessionTicketKeysRef []gwapiv1.SecretObjectReference `json:"sessionTicketKeysRef,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@guydc guydc Sep 25, 2024

Choose a reason for hiding this comment

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

after discussion yesterday, I reduced the scope of this PR to only deal with enable/disable of resumption. The types now include an explanation of performance, HA, functional and security impacts of different resumption methods.

// Note that improper handling of session ticket encryption keys may result in loss of secrecy.
// https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/transport_sockets/tls/v3/common.proto#extensions-transport-sockets-tls-v3-tlssessionticketkeys
// Default: true
Enabled *bool `json:"enabled,omitempty"`
Copy link
Member

@zhaohuabing zhaohuabing Sep 23, 2024

Choose a reason for hiding this comment

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

If we add an intermediate layer, Enabled can replaced with a Type, aligning it with other EG APIs.

SessionResumption:
  Type: Stateless
  keys:
  - ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good input, I adopted this format.

Copy link
Member

@zhaohuabing zhaohuabing Sep 26, 2024

Choose a reason for hiding this comment

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

Rethink on this, a fixed list of 2 elements seems a bit strange, what about the following structure? cc @arkodg as he always has great idea on how to shape the API :-)

SessionResumptionSettings:
   stateful: {}
   stateless: {}

@guydc
Copy link
Contributor Author

guydc commented Sep 25, 2024

Following yesterday's community meeting, some additional industry context.

Currently, Mozilla's SSL config generator recommends disabling stateless resumption (session tickets) for nginx, apache and haproxy for security reasons.

This is mostly due to insufficient rotation of session ticket encryption keys in these projects. There is an ongoing discussion on changing the recommendation for newer versions of nginx where keys are rotated: mozilla/server-side-tls#135.

BoringSSL rotates encryption keys by default every 48 hours: https://commondatastorage.googleapis.com/chromium-boringssl-docs/ssl.h.html#Session-tickets. Envoy doesn't change this behavior or make the rotation schedule configurable. Industry leaders like cloudflare rotate session ticket encryption keys every hour: https://blog.cloudflare.com/keyless-ssl-the-nitty-gritty-technical-details/.

There is no security recommendation to disable stateful session resumption. However:

nginx ingress by default disables stateful and stateless session resumption, but makes it possible to opt-in:

I propose that we change the current behavior and disable both resumption methods by default, but allow users to opt-in similar to nginx ingress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants