cloudfoundry / routing-release

This is the BOSH release for cloud foundry routers
Apache License 2.0
42 stars 106 forks source link

Gorouter does not support session affinity for WebSockets #351

Open domdom82 opened 1 year ago

domdom82 commented 1 year ago

Is this a security vulnerability?

No.

Issue

Gorouter supports session affinity as described in the docs. However, this support currently works only for regular HTTP traffic. Requests to WebSocket apps ignore JSESSIONID or other session cookies and will be routed randomly instead.

Affected Versions

All.

Context

Steps to Reproduce

  1. Push a CF app that implements a WebSocket that sets a JSESSIONID cookie
  2. Scale the app to two or more instances
  3. Re-use the JSESSIONID cookie in the next request
  4. Observe the backend instance that is used with the request

Expected result

The same instance is used that has originated the JSESSIONID cookie

Current result

A random instance is used. JSESSIONID cookie is ignored.

Possible Fix

maxmoehl commented 12 months ago

IMO option 2 (dedicated handler, communicate via RequestInfo) is the most desirable. RequestInfo is already used to communicate / collect information related to that request and it clearly separates the logic (hopefully) making the code more maintainable.