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

[balsa] Fix header size limit error messages. #22447

Merged
merged 9 commits into from
Aug 11, 2022
Merged

[balsa] Fix header size limit error messages. #22447

merged 9 commits into from
Aug 11, 2022

Conversation

bencebeky
Copy link
Contributor

@bencebeky bencebeky commented Jul 28, 2022

Change error messages for too large headers that match
ConnectionImpl::checkMaxHeadersSize() behavior.

When http-parser parses a piece of data, it immediately calls
ParserCallbacks::onHeaderField() or ParserCallbacks::onHeaderValue()
with the current fragment of header key or value, and
ConnectionImpl::checkMaxHeadersSize() checks size limit each time.

On the other hand, BalsaFrame buffers the header key and value and only
calls BalsaVisitorInterface::OnHeader() when the given header completes.
In order to prevent from memory attacks, the header size limit is passed
to BalsaFrame through BalsaParser constructor, and BalsaFrame internally
enforces the limit while parsing.

Tracking issue: #21245

Signed-off-by: Bence Béky bnc@google.com

Commit Message: [balsa] Fix header size limit error messages.
Additional Description: n/a
Risk Level: low, BalsaParser is behind default-false flag
Testing: //test/common/http/http1:codec_impl_test
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

Change error messages for too large headers that match
ConnectionImpl::checkMaxHeadersSize() behavior.

When http-parser parses a piece of data, it immediately calls
ParserCallbacks::onHeaderField() or ParserCallbacks::onHeaderValue()
with the current fragment of header key or value, and
ConnectionImpl::checkMaxHeadersSize() checks size limit each time.

On the other hand, BalsaFrame buffers the header key and value and only
calls BalsaVisitorInterface::OnHeader() when the given header completes.
In order to prevent from memory attacks, the header size limit is passed
to BalsaFrame through BalsaParser constructor, and BalsaFrame internally
enforces the limit while parsing.

Signed-off-by: Bence Béky <bnc@google.com>
@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: #22447 was opened by bencebeky.

see: more, trace.

@bencebeky
Copy link
Contributor Author

/assign @diannahu @birenroy

diannahu
diannahu previously approved these changes Aug 1, 2022
Copy link
Contributor

@diannahu diannahu left a comment

Choose a reason for hiding this comment

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

Small functional delta for large test enablement!

@bencebeky
Copy link
Contributor Author

In fact this PR needs a little more work.

/unassign @diannahu @birenroy

Signed-off-by: Bence Béky <bnc@google.com>
Signed-off-by: Bence Béky <bnc@google.com>
Signed-off-by: Bence Béky <bnc@google.com>
… flag.

Signed-off-by: Bence Béky <bnc@google.com>
@bencebeky
Copy link
Contributor Author

PTAL. Now it's ready for review. (Changed error code based on error message returned by Balsa, which allowed for enabling two more tests.)

/assign @diannahu @birenroy

Signed-off-by: Bence Béky <bnc@google.com>
@birenroy
Copy link
Contributor

birenroy commented Aug 8, 2022

LGTM

@bencebeky
Copy link
Contributor Author

Thank you both for the reviews.

@bencebeky
Copy link
Contributor Author

Kevin: PTAL

/assign @KBaichoo

@bencebeky bencebeky marked this pull request as ready for review August 8, 2022 16:59
Signed-off-by: Bence Béky <bnc@google.com>
@KBaichoo
Copy link
Contributor

KBaichoo commented Aug 9, 2022

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #22447 (comment) was created by @KBaichoo.

see: more, trace.

Copy link
Contributor

@KBaichoo KBaichoo left a comment

Choose a reason for hiding this comment

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

lgtm; I think CI is a flake; restarted it

source/common/http/http1/codec_impl.cc Show resolved Hide resolved
@KBaichoo
Copy link
Contributor

KBaichoo commented Aug 9, 2022

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #22447 (comment) was created by @KBaichoo.

see: more, trace.

Signed-off-by: Bence Béky <bnc@google.com>
@KBaichoo
Copy link
Contributor

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #22447 (comment) was created by @KBaichoo.

see: more, trace.

@KBaichoo KBaichoo enabled auto-merge (squash) August 11, 2022 15:17
@KBaichoo KBaichoo merged commit eb352bb into envoyproxy:main Aug 11, 2022
@bencebeky bencebeky deleted the trailers branch September 6, 2022 13:06
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.

5 participants