Skip to content

Conversation

olix0r
Copy link
Member

@olix0r olix0r commented Sep 22, 2021

The inbound proxy sets the l5d-proxy-error and l5d-proxy-connection
headers when an error is encountered. This leaks information about the
proxy to potentially untrusted clients.

This change modifies the error handling behavior to only emit these
headers from the inbound proxy when the client uses mesh identity.

In doing so, we modify the inbound::NewSetIdentiyHeader layer to use
ExtractParam<tls::ConditionalServerTls, _> to parameterize the server
connection's identity to be consistent with the rescue parameters. This
precipitated modifying the default impls for ExtractParam so that we
can provide an impl for () that simply uses the target type. A new
CloneParam type is introduced to replicate the former behavior.

The inbound proxy sets the `l5d-proxy-error` and `l5d-proxy-connection`
headers when an error is encountered. This leaks information about the
proxy to potentially untrusted clients.

This change modifies the error handling behavior to only emit these
headers from the inbound proxy when the client uses mesh identity.

In doing so, we modify the `inbound::NewSetIdentiyHeader` layer to use
`ExtractParam<tls::ConditionalServerTls, _>` to parameterize the server
connection's identity to be consistent with the rescue parameters. This
precipitated modifying the default impls for `ExtractParam` so that we
can provide an impl for `()` that simply uses the target type. A new
`CloneParam` type is introduced to replicate the former behavior.
@olix0r olix0r requested a review from a team September 22, 2021 16:40
Copy link
Contributor

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

overall, this looks good, but i was curious about the potential impact of moving all error recovery into ServerRescue --- there's a comment in the stack about ClientRescue being necessary to ensure error metrics aren't double-counted; what's the story with that?

Copy link
Contributor

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

cool that we were able to back out the metrics change and it still works --- lgtm!

@olix0r olix0r merged commit 7b3014b into main Sep 22, 2021
@olix0r olix0r deleted the ver/error-meshed branch September 22, 2021 20:25
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Sep 23, 2021
This release improves the proxy's error handling, introducing a new
`l5d-proxy-connection` header to signal from an inbound proxy when its
peers outbound connections should be torn down.

Furthermore, error handling has been improved so that the
`l5d-proxy-error` header is only sent to trusted peers--the inbound
proxy only emits this header when its client is meshed; and the outbound
proxy can be configured to disable these headers via configuration.

---

* build(deps): bump hyper from 0.14.12 to 0.14.13 (linkerd/linkerd2-proxy#1273)
* build(deps): bump tracing-subscriber from 0.2.22 to 0.2.23 (linkerd/linkerd2-proxy#1274)
* tracing: use `Span::or_current` when spawning tasks (linkerd/linkerd2-proxy#1272)
* dns: Log TTL with resolution (linkerd/linkerd2-proxy#1275)
* error-respond: Support stack target configuration (linkerd/linkerd2-proxy#1276)
* build(deps): bump tracing-subscriber from 0.2.23 to 0.2.24 (linkerd/linkerd2-proxy#1277)
* build(deps): bump tracing from 0.1.27 to 0.1.28 (linkerd/linkerd2-proxy#1278)
* build(deps): bump tokio from 1.11.0 to 1.12.0 (linkerd/linkerd2-proxy#1279)
* build(deps): bump http from 0.2.4 to 0.2.5 (linkerd/linkerd2-proxy#1280)
* Support a `l5d-proxy-connection: close` header (linkerd/linkerd2-proxy#1281)
* Avoid emitting informational headers to untrusted clients (linkerd/linkerd2-proxy#1282)
* outbound: Only honor the `l5d-proxy-connection` header when meshed (linkerd/linkerd2-proxy#1283)
* outbound: Disable informational headers by config (linkerd/linkerd2-proxy#1284)
* outbound: Strip peer-sent `l5d-proxy-error` headers (linkerd/linkerd2-proxy#1285)
alpeb pushed a commit to linkerd/linkerd2 that referenced this pull request Sep 23, 2021
This release improves the proxy's error handling, introducing a new
`l5d-proxy-connection` header to signal from an inbound proxy when its
peers outbound connections should be torn down.

Furthermore, error handling has been improved so that the
`l5d-proxy-error` header is only sent to trusted peers--the inbound
proxy only emits this header when its client is meshed; and the outbound
proxy can be configured to disable these headers via configuration.

---

* build(deps): bump hyper from 0.14.12 to 0.14.13 (linkerd/linkerd2-proxy#1273)
* build(deps): bump tracing-subscriber from 0.2.22 to 0.2.23 (linkerd/linkerd2-proxy#1274)
* tracing: use `Span::or_current` when spawning tasks (linkerd/linkerd2-proxy#1272)
* dns: Log TTL with resolution (linkerd/linkerd2-proxy#1275)
* error-respond: Support stack target configuration (linkerd/linkerd2-proxy#1276)
* build(deps): bump tracing-subscriber from 0.2.23 to 0.2.24 (linkerd/linkerd2-proxy#1277)
* build(deps): bump tracing from 0.1.27 to 0.1.28 (linkerd/linkerd2-proxy#1278)
* build(deps): bump tokio from 1.11.0 to 1.12.0 (linkerd/linkerd2-proxy#1279)
* build(deps): bump http from 0.2.4 to 0.2.5 (linkerd/linkerd2-proxy#1280)
* Support a `l5d-proxy-connection: close` header (linkerd/linkerd2-proxy#1281)
* Avoid emitting informational headers to untrusted clients (linkerd/linkerd2-proxy#1282)
* outbound: Only honor the `l5d-proxy-connection` header when meshed (linkerd/linkerd2-proxy#1283)
* outbound: Disable informational headers by config (linkerd/linkerd2-proxy#1284)
* outbound: Strip peer-sent `l5d-proxy-error` headers (linkerd/linkerd2-proxy#1285)
cratelyn added a commit that referenced this pull request Feb 13, 2025
`linkerd-app-core` includes an error recovery body middleware. this middleware will gracefully catch and report errors encountered when polling an inner body, and via an `R`-typed recovery strategy provided by the caller, will attempt to map the error to a gRPC status code denoting an error.

before we upgrade to hyper 1.0 in service of linkerd/linkerd2#8733, we add some test coverage to ensure that we preserve the behavior of this middleware.

see:
* linkerd/linkerd2#8733
* #3614.

for historical context on this tower layer, see:
* #222
* #1246
* #1282

---

* refactor(http/retry): outline `ForwardCompatibleBody<B>`

in #3559 (4b53081), we introduced a backported `Frame<T>` type, and a
`ForwardCompatibleBody<B>` type that allows us to interact with a
`http_body::Body` circa 0.4.6 in terms of frame-based interfaces that
match those of the 1.0 interface.

see linkerd/linkerd2#8733 for more information on upgrading hyper.

in #3559, we narrowly added this as an internal submodule of the
`linkerd-http-retry` library. these facilities however, would have
utility in other places such as `linkerd-app-core`.

this commit pulls these compatibility shims out into a
`linkerd-http-body-compat` library so that they can be imported and
reused elsewhere.

Signed-off-by: katelyn martin <kate@buoyant.io>

* nit(http/body-compat): tidy `combinators` imports

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): hoist `errors::code_header` helper

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): `l5d-*` constants are headers

these are header values. `http::HeaderName` has a const fn constructor,
so let's use that.

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): grpc constants are headers

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): hoist `l5d-` and `grpc-` constants

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): outline `ResponseBody` middleware

we'll add a few tests for this middleware shortly.

this commit moves this middleware out into its own submodule.

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): encapsulate `ResponseBody` enum

for other body middleware, we hide inner enum variants and their
constituent members by using the "inner" pattern.

this commit tweaks `ResponseBody` to follow suit, such that it now holds
an `Inner`, but does not expose its passthrough and rescue variants to
callers.

Signed-off-by: katelyn martin <kate@buoyant.io>

* docs(app/core): document `ResponseBody<R, B>`

this adds a small documentation comment describing what this type does.

Signed-off-by: katelyn martin <kate@buoyant.io>

* refactor(app/core): a unit test suite for rescue body

this commit introduces a test suite for our error recovery middleware.

this body middleware provides a mechanism to "rescue" errors, gracefully
mapping an error encountered when polling a gRPC body into e.g. trailers
with a gRPC status code.

before we upgrade this middleware in service of linkerd/linkerd2#8733,
we add some test coverage to ensure that we preserve this middleware.

Signed-off-by: katelyn martin <kate@buoyant.io>

---------

Signed-off-by: katelyn martin <kate@buoyant.io>
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