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

http: clear hop by hop TE header #30535

Merged
merged 2 commits into from
Nov 30, 2023
Merged

Conversation

alyssawilk
Copy link
Contributor

@alyssawilk alyssawilk commented Oct 26, 2023

Changes Envoy to clear TE header by default, as it is a hop by hop header and should not be forwarded on.

Risk Level: medium (behavioral change)
Testing: new e2e test
Docs Changes: n/a
Release Notes: inline.
[Optional Runtime guard:] yes.
Fixes #30362

@repokitteh-read-only
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #30535 was opened by alyssawilk.

see: more, trace.

@repokitteh-read-only
Copy link

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).

🐱

Caused by: #30535 was opened by alyssawilk.

see: more, trace.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Contributor

@RyanTheOptimist RyanTheOptimist left a comment

Choose a reason for hiding this comment

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

Looks great!

@@ -1375,8 +1377,9 @@ TEST_P(HeaderIntegrationTest, TestTeHeaderPassthrough) {
});
}

// Validates TE header is stripped if it contains an unsupported value
// Validates TE header was stripped if it contains an unsupported value
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Your call, but I'd be inclined to use the present tense here as it's describing what the test is going to do, not what it has done. But totally your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@@ -1341,8 +1341,10 @@ TEST_P(HeaderIntegrationTest, PathWithEscapedSlashesRedirected) {
});
}

// Validates TE header is forwarded if it contains a supported value
// Validates TE header was forwarded if it contains a supported value
// It is now treated as the hop by hop header it is.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove this comment? I'm not sure that I understand why it's here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

- area: http
change: |
Sanitize the hop by hop TE header from downstream request headers. This change can be temporarily reverted
by setting ``envoy.reloadable_features.sanitize_te`` to false.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this flag sanitize the TE header, or does it remove it?

default_request_headers_.setTE("gzip");
} else {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Early return:

if (downstreamProtocol() != Http::CodecType::HTTP1) {
  return;
}
default_request_headers_.setTE("gzip");

Optionally put this early return at the top of the test to make it clear that it's H1-specific.

mattklein123
mattklein123 previously approved these changes Nov 30, 2023
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@RyanTheOptimist RyanTheOptimist merged commit d4ed8d4 into envoyproxy:main Nov 30, 2023
105 checks passed
@quantumsheep
Copy link
Contributor

Since Envoy 1.29 I get Missing :te header when proxying to a Python-gRPC API because of this.

Removing the TE isn't the solution. We should replace it by trailers.

@alyssawilk
Copy link
Contributor Author

So thankfully this is runtime guarded so you should be able to reinstate prior behavior with a config change.

I think if you want the envoy-upstream hop to support trailers you should just add request headers "te: trailers" to the outgoing request.

@ejona86
Copy link
Contributor

ejona86 commented Feb 8, 2024

I think if you want the envoy-upstream hop to support trailers you should just add request headers "te: trailers" to the outgoing request.

If you are meaning unconditionally, that seems a bit simplistic. That ignores whether the originating client supports trailers. From RFC 7230 §4.1.2:

The presence of the keyword "trailers" indicates that the client is
willing to accept trailer fields in a chunked transfer coding, as
defined in Section 4.1.2, on behalf of itself and any downstream
clients.

"any downstream clients" being the important part. So you'd want to make it conditional based on the originating request.

@RyanTheOptimist
Copy link
Contributor

I think if you want the envoy-upstream hop to support trailers you should just add request headers "te: trailers" to the outgoing request.

If you are meaning unconditionally, that seems a bit simplistic. That ignores whether the originating client supports trailers. From RFC 7230 §4.1.2:

The presence of the keyword "trailers" indicates that the client is
willing to accept trailer fields in a chunked transfer coding, as
defined in Section 4.1.2, on behalf of itself and any downstream
clients.

"any downstream clients" being the important part. So you'd want to make it conditional based on the originating request.

Oh, interesting. Yes, I think that's a good point. Envoy itself is able to process trailers and pass them along, but it's only "safe" to do that in the case where Envoy knows that the downstream client is able to process trailers. The client, of course, indicates this by sending "trailers" in te.

Does that sound right?

RyanTheOptimist pushed a commit that referenced this pull request Feb 12, 2024
Official grpc library does not allow empty TE header. This causes an issue when proxying requests through Envoy which currently deletes the TE header since #30535.

I opened a related MR on the grpc library to allow this header to be empty as the HTTP/2 RFC allows it but it might cause issues with other libraries.

Risk Level: medium (behavioral change)
Testing: modified an existing test
Docs Changes: n/a
Release Notes: inline
Platform Specific Features:
Runtime guard: keep the previous one

Signed-off-by: Nathanael DEMACON <ndemacon@scaleway.com>
ctvera pushed a commit to ctvera/envoy that referenced this pull request Mar 4, 2024
)

Official grpc library does not allow empty TE header. This causes an issue when proxying requests through Envoy which currently deletes the TE header since envoyproxy#30535.

I opened a related MR on the grpc library to allow this header to be empty as the HTTP/2 RFC allows it but it might cause issues with other libraries.

Risk Level: medium (behavioral change)
Testing: modified an existing test
Docs Changes: n/a
Release Notes: inline
Platform Specific Features:
Runtime guard: keep the previous one

Signed-off-by: Nathanael DEMACON <ndemacon@scaleway.com>
ctvera pushed a commit to ctvera/envoy that referenced this pull request Mar 15, 2024
)

Official grpc library does not allow empty TE header. This causes an issue when proxying requests through Envoy which currently deletes the TE header since envoyproxy#30535.

I opened a related MR on the grpc library to allow this header to be empty as the HTTP/2 RFC allows it but it might cause issues with other libraries.

Risk Level: medium (behavioral change)
Testing: modified an existing test
Docs Changes: n/a
Release Notes: inline
Platform Specific Features:
Runtime guard: keep the previous one

Signed-off-by: Nathanael DEMACON <ndemacon@scaleway.com>
@alyssawilk alyssawilk deleted the te branch March 19, 2024 19:46
phlax pushed a commit to phlax/envoy that referenced this pull request Mar 20, 2024
)

Official grpc library does not allow empty TE header. This causes an issue when proxying requests through Envoy which currently deletes the TE header since envoyproxy#30535.

I opened a related MR on the grpc library to allow this header to be empty as the HTTP/2 RFC allows it but it might cause issues with other libraries.

Risk Level: medium (behavioral change)
Testing: modified an existing test
Docs Changes: n/a
Release Notes: inline
Platform Specific Features:
Runtime guard: keep the previous one

Signed-off-by: Nathanael DEMACON <ndemacon@scaleway.com>
Signed-off-by: Ryan Northey <ryan@synca.io>
htuch pushed a commit that referenced this pull request Mar 21, 2024
) (#33018)

Official grpc library does not allow empty TE header. This causes an issue when proxying requests through Envoy which currently deletes the TE header since #30535.

I opened a related MR on the grpc library to allow this header to be empty as the HTTP/2 RFC allows it but it might cause issues with other libraries.

Risk Level: medium (behavioral change)
Testing: modified an existing test
Docs Changes: n/a
Release Notes: inline
Platform Specific Features:
Runtime guard: keep the previous one

Signed-off-by: Nathanael DEMACON <ndemacon@scaleway.com>
Signed-off-by: Ryan Northey <ryan@synca.io>
Co-authored-by: Nathanael Demacon <nathanael.dmc@outlook.fr>
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.

Upstream H2 connection reset when sending invalid TE header value
5 participants