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

test: fix use after free in oauth_integration_test #14103

Merged

Conversation

antoniovicente
Copy link
Contributor

Commit Message:
test: fix use after free in oauth_integration_test

The client request stream can be deleted under the call stack of Envoy::IntegrationCodecClient::startRequest if the proxy replies quickly enough. Attempts to send an end stream on that request result in use-after-free on the client stream in cases where the client processed the full reply inside startRequest.
Additional Description:
Risk Level: n/a test-only
Testing: n/a
Docs Changes: n/a
Release Notes: n/a
Fixes #12960

The client request stream can be deleted under the call stack of Envoy::IntegrationCodecClient::startRequest if the proxy replies quickly enough. Attempts to send an end stream on that request result in use-after-free on the client stream in cases where the client processed the full reply inside startRequest.

Signed-off-by: Antonio Vicente <avd@google.com>
Copy link
Member

@rgs1 rgs1 left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for debugging and fixing.

@@ -91,8 +91,6 @@ TEST_F(OauthIntegrationTest, UnauthenticatedFlow) {
{":authority", "authority"}};
auto encoder_decoder = codec_client_->startRequest(headers);

Buffer::OwnedImpl buffer;
Copy link
Member

Choose a reason for hiding this comment

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

I actually wonder if responding before the request is complete (since this is effectively what is tested now) is going to break some clients who don't handle this well? Unrelated to this test fix but maybe something to think about in the future. cc @rgs1.

Copy link
Member

Choose a reason for hiding this comment

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

Shall we add the above as a note?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it might be worth it to document this somewhere but up to you all as whether to do it in here or a follow up, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is generic H2 behavior. The proxy does have fully request headers for the GET by the time it replies. I'll make a note to try to look at the more general issue in test frameworks.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I know it's correct/generic behavior, I was just suggesting that I can envision some clients not dealing with this well so we should keep that in mind for future support queries.

@lizan lizan added the backport/approved Approved backports to stable releases label Nov 19, 2020
@htuch htuch merged commit e4fd69d into envoyproxy:master Nov 19, 2020
antoniovicente added a commit to antoniovicente/envoy that referenced this pull request Nov 20, 2020
The client request stream can be deleted under the call stack of Envoy::IntegrationCodecClient::startRequest if the proxy replies quickly enough. Attempts to send an end stream on that request result in use-after-free on the client stream in cases where the client processed the full reply inside startRequest.

Fixes envoyproxy#12960

Signed-off-by: Antonio Vicente <avd@google.com>
cpakulski pushed a commit to cpakulski/envoy that referenced this pull request Nov 20, 2020
The client request stream can be deleted under the call stack of Envoy::IntegrationCodecClient::startRequest if the proxy replies quickly enough. Attempts to send an end stream on that request result in use-after-free on the client stream in cases where the client processed the full reply inside startRequest.

Fixes envoyproxy#12960

Signed-off-by: Antonio Vicente <avd@google.com>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
cpakulski pushed a commit to cpakulski/envoy that referenced this pull request Nov 20, 2020
The client request stream can be deleted under the call stack of Envoy::IntegrationCodecClient::startRequest if the proxy replies quickly enough. Attempts to send an end stream on that request result in use-after-free on the client stream in cases where the client processed the full reply inside startRequest.

Fixes envoyproxy#12960

Signed-off-by: Antonio Vicente <avd@google.com>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>
antoniovicente added a commit that referenced this pull request Nov 20, 2020
The client request stream can be deleted under the call stack of Envoy::IntegrationCodecClient::startRequest if the proxy replies quickly enough. Attempts to send an end stream on that request result in use-after-free on the client stream in cases where the client processed the full reply inside startRequest.

Fixes #12960

Signed-off-by: Antonio Vicente <avd@google.com>
Signed-off-by: Christoph Pakulski <christoph@tetrate.io>

Co-authored-by: antonio <avd@google.com>
andreyprezotto pushed a commit to andreyprezotto/envoy that referenced this pull request Nov 24, 2020
The client request stream can be deleted under the call stack of Envoy::IntegrationCodecClient::startRequest if the proxy replies quickly enough. Attempts to send an end stream on that request result in use-after-free on the client stream in cases where the client processed the full reply inside startRequest.

Fixes envoyproxy#12960

Signed-off-by: Antonio Vicente <avd@google.com>
qqustc pushed a commit to qqustc/envoy that referenced this pull request Nov 24, 2020
The client request stream can be deleted under the call stack of Envoy::IntegrationCodecClient::startRequest if the proxy replies quickly enough. Attempts to send an end stream on that request result in use-after-free on the client stream in cases where the client processed the full reply inside startRequest.

Fixes envoyproxy#12960

Signed-off-by: Antonio Vicente <avd@google.com>
Signed-off-by: Qin Qin <qqin@google.com>
@cpakulski
Copy link
Contributor

Backported to rel 1.16. Releases 1.13-1.15 do not have oauth_integration_test and are not affected.
Removing backport/approved label.

@cpakulski cpakulski removed the backport/approved Approved backports to stable releases label Nov 25, 2020
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.

Test flake in OauthIntegrationTest.UnauthenticatedFlow
6 participants