Skip to content

http: guard against multiple 100 responses - #2567

Merged
mattklein123 merged 8 commits into
envoyproxy:masterfrom
alyssawilk:in_the_end_there_can_be_only_1_100_continue
Feb 12, 2018
Merged

mattklein123 merged 8 commits into
envoyproxy:masterfrom
alyssawilk:in_the_end_there_can_be_only_1_100_continue

Conversation

@alyssawilk

@alyssawilk alyssawilk commented Feb 9, 2018 •

Copy link
Copy Markdown
Contributor

Description:
If not proxying 100-Continue, swallow 100-continues.
Also handle the case of multiple continues headers "cleanly" by resetting the stream, rather than crashing. Support for responses with multiple headers, such as 103 (early hint) can be added when there's a need.

Risk Level: Medium (on top of a high risk feature)
Testing: Lots and lots of extended integration tests.
Docs Changes: envoyproxy/data-plane-api#492
Release Notes: 100-continue support already docced.
Fixes #2563

@mattklein123

Copy link
Copy Markdown
Member

@alyssawilk at a high level LGTM. I wouldn't mark "Fixes #2563" until we fully protect against multiple informational headers from upstream (wasn't sure if you meant a follow up in this PR, or in another PR).

@alyssawilk

Copy link
Copy Markdown
Contributor Author

Fair. Just to sanity check we're fine just resetting the stream on multiple non-informational headers with a comment that we'll add support iff anyone wants to pick it up?

@mattklein123

Copy link
Copy Markdown
Member

Just to sanity check we're fine just resetting the stream on multiple non-informational headers with a comment that we'll add support iff anyone wants to pick it up?

Absolutely. Or even just ignore them. Either way.

@alyssawilk alyssawilk changed the title WIP: Guard against multiple 100-Continues Guard against multiple 100s Feb 12, 2018
@alyssawilk alyssawilk changed the title Guard against multiple 100s http: guard against multiple 100 responses Feb 12, 2018
@alyssawilk

Copy link
Copy Markdown
Contributor Author

(New unit test for the "don't crash on lots of headers" plus verified the ASAN use-after-free crash turns into a reset stream)

@mattklein123 mattklein123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice, two small comments.

// supports. Even if this is valid HTTP (something like 103 early hints) fail here
// rather than trying to push unexpected headers through the Envoy pipeline as that
// will likely result in Envoy crashing.
throw CodecProtocolException("Unexpected 'trailers' with no end stream.");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

WDYT about resetting the stream vs. throwing a codec protocol exception? The latter will tear down the entire connection? I think it's probably not a big deal either way but throwing it out there. Whatever we do I think we should add a stat for this case similar to the headers_cb_no_stream_ stat so we have something to look at just in case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it would be cleaner, but with the defered reset logic I'd be uncomfortable doing that without a regression test, which I think require a bunch more plumbing to allow the codec client to bypass some of our asserts. I think I'll add a comment explaining that killing the connection, while suboptimal, is better than a crash and safer than a reset.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh and added a stat but I'm totally failing to find where the h2 codec stats are documented. Pointers appreciated.

EXPECT_CALL(response_decoder_, decodeHeaders_(_, false));
response_encoder_->encodeHeaders(early_hint_headers, false);

EXPECT_THROW(response_encoder_->encodeHeaders(early_hint_headers, false), CodecProtocolException);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: It's a little hard to tell whether this is throwing when encodeHeaders is called, or when we process on the other side. Is it possible to disable byte transfer temporarily and then check for an exception when we parse bytes on the other side?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Switching to EXPECT_THROW_WITH_MESSAGE which I think makes it clear where the exception is coming from. WDYT?

@mattklein123

Copy link
Copy Markdown
Member

plus verified the ASAN use-after-free crash turns into a reset stream

Just to make sure I understand, that's a manual verification right? (When you remove the other fix). There isn't a test that covers this? That's fine, I just want to make sure I'm not missing something.

@alyssawilk

alyssawilk commented Feb 12, 2018 via email

Copy link
Copy Markdown
Contributor Author

Signed-off-by: Alyssa Wilk <[email protected]>

@mattklein123 mattklein123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. We probably don't have docs for the h2 specific stats if you searched and you didn't find them. :(

Not sure of the best place to put them. I would just pick a place or just open an issue to track they are missing. Thanks for thinking of the docs!

Comment thread source/common/http/http2/codec_impl.h Outdated
COUNTER(header_overflow) \
COUNTER(trailers) \
COUNTER(headers_cb_no_stream)
COUNTER(headers_cb_no_stream) \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: align '\'

@mattklein123
mattklein123 merged commit 44e5768 into envoyproxy:master Feb 12, 2018
@alyssawilk
alyssawilk deleted the in_the_end_there_can_be_only_1_100_continue branch October 10, 2018 19:55
Shikugawa pushed a commit to Shikugawa/envoy that referenced this pull request Mar 28, 2020
* Add test for stats+metadata exchange filter for http

Cleanup ports

Format http server

Add ability to add client and server yaml files that  test finally uses

Add more validation for source and destination app in http test

Upgrade to latest envoy-wasm

Fix failures in tests

Fix lint errors

Fix lint errors

Fix tests

Fix tests

* Add destination_port in stats config
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Risk Level: low (test only)
Testing: yes
Docs Changes: n/a
Release Notes: n/a
Fixes #2546

Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: JP Simard <[email protected]>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Risk Level: low (test only)
Testing: yes
Docs Changes: n/a
Release Notes: n/a
Fixes #2546

Signed-off-by: Alyssa Wilk <[email protected]>
Signed-off-by: JP Simard <[email protected]>
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