Skip to content

v6.1.0 — Security hardening and dependency updates

Latest

Choose a tag to compare

@jkyberneees jkyberneees released this 25 Nov 10:30
1b5f7dd

Security and reliability release. Updates every dependency to its latest version and fixes the findings of a security review, a functional review and two adversarial reviews.

No configuration changes are required, but error handling and the upgraded dependencies are stricter. See Breaking Changes → v6.1.x before upgrading.

Security

  • WebSockets: messages are relayed with backpressure and nothing is read from the client until the upstream connection is open. A single client could previously make the gateway buffer hundreds of MB.
  • WebSockets: the upstream gets 30 seconds to complete the opening handshake (timeout route option), then the client is closed with code 4504.
  • WebSockets: paths with . or .. segments, also encoded, get a 400 as HTTP routes do. Paths longer than 1024 characters match no route.
  • WebSockets: the onOpen hook receives the upgrade request as third argument, so connections can be authenticated and their Origin checked.
  • Lambda: responses that can't be delivered (invalid status code or header values, unexpected payloads, invocation errors without a status code) get a 500 or 502. They used to crash the process.
  • Hostnames hook: host names longer than 253 characters are not matched, glob matching them could block the event loop.
  • Request validation (fast-proxy-lite 1.2): forwarded paths starting with // or containing backslashes or control characters, lower case methods and cross-origin urlRewrite targets get a 400, CONNECT gets a 405.

Fixes

  • A failing onResponse hook (sync throw or rejected promise) calls onError once and gets an error response without the upstream headers. A rejected async hook used to be an unhandled rejection with a hanging request.
  • Custom proxy types (proxyFactory) no longer receive a no-op onResponse hook, which made fast-proxy-lite style proxies hang.
  • HTTP/2 streams are reset when the upstream response fails midway (default onResponse hook).
  • HEAD, 204 and 304 responses are not buffered into a content-length: 0 response anymore.
  • The hostnames hook uses the :authority pseudo-header of HTTP/2 requests.
  • TypeScript: subProtocols: string[], prefix: string | string[] and sync onOpen hooks for WebSocket routes, gateway(opts) requires its argument, no dependency on the Express global namespace.
  • pump is a declared dependency.
  • The circuit breaker and rate limit demos work again, and the caching docs show the middleware order that keeps cache entries separated per user.

Dependencies

  • fast-proxy-lite 1.1.3 → 1.2.0
  • http-cache-middleware 1.4.1 → 2.0.0 (new cache entry format, entries stored by v1 are ignored)
  • faye-websocket 0.11.4 → 0.12.0 (optional, WebSocket routes)

Upgrade notes

  • A custom proxy calling opts.onResponse unconditionally throws when the route defines no hook: check that it is defined.
  • timeout on a WebSocket route was ignored, it is now the upstream handshake timeout.
  • With backpressure, two WebSocket peers that both stop reading while their own writes are backed up stall each other, as they would on a direct connection.
  • req.query remains the source of the forwarded query string. A query string set through req.url in urlRewrite or onRequest is only forwarded with disableQsOverwrite: true.

Full Changelog: v6.0.0...v6.1.0