Repository navigation
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 (
timeoutroute option), then the client is closed with code4504. - WebSockets: paths with
.or..segments, also encoded, get a400as HTTP routes do. Paths longer than 1024 characters match no route. - WebSockets: the
onOpenhook receives the upgrade request as third argument, so connections can be authenticated and theirOriginchecked. - Lambda: responses that can't be delivered (invalid status code or header values, unexpected payloads, invocation errors without a status code) get a
500or502. 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-originurlRewritetargets get a400,CONNECTgets a405.
Fixes
- A failing
onResponsehook (sync throw or rejected promise) callsonErroronce 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-oponResponsehook, which made fast-proxy-lite style proxies hang. - HTTP/2 streams are reset when the upstream response fails midway (default
onResponsehook). HEAD,204and304responses are not buffered into acontent-length: 0response anymore.- The hostnames hook uses the
:authoritypseudo-header of HTTP/2 requests. - TypeScript:
subProtocols: string[],prefix: string | string[]and synconOpenhooks for WebSocket routes,gateway(opts)requires its argument, no dependency on theExpressglobal namespace. pumpis 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-lite1.1.3 → 1.2.0http-cache-middleware1.4.1 → 2.0.0 (new cache entry format, entries stored by v1 are ignored)faye-websocket0.11.4 → 0.12.0 (optional, WebSocket routes)
Upgrade notes
- A custom proxy calling
opts.onResponseunconditionally throws when the route defines no hook: check that it is defined. timeouton 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.queryremains the source of the forwarded query string. A query string set throughreq.urlinurlRewriteoronRequestis only forwarded withdisableQsOverwrite: true.
Full Changelog: v6.0.0...v6.1.0