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

router: Validate the header string in header parser. #32559

Closed
wants to merge 6 commits into from

Conversation

tyxia
Copy link
Member

@tyxia tyxia commented Feb 23, 2024

In production, code/parser level is centralized place for header validation safeguarding against invalid headers. Unified Header Validation is long-term solution for header validation.

However, in the fuzzer, we have seen asserts triggered by invalidate header string and it is before above header validation happens.

It probably doesn't hurt to do header validation/rejection early to avoid invalid header being further evaluated/processed unless overhead of check is a concern. Open to discussion.

Signed-off-by: tyxia <tyxia@google.com>
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: #32559 was opened by tyxia.

see: more, trace.

Signed-off-by: tyxia <tyxia@google.com>
Signed-off-by: tyxia <tyxia@google.com>
Signed-off-by: tyxia <tyxia@google.com>
Signed-off-by: tyxia <tyxia@google.com>
…r_parser

Signed-off-by: tyxia <tyxia@google.com>
@tyxia
Copy link
Member Author

tyxia commented Feb 24, 2024

/retest

@tyxia tyxia changed the title reject invalid router: Validate the header string in header parser. Feb 26, 2024
@tyxia tyxia marked this pull request as ready for review February 26, 2024 18:36
@mattklein123 mattklein123 self-assigned this Feb 27, 2024
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.

/wait

Comment on lines +165 to +170
// Skip any invalid header value.
// The validity of the header key has already been checked as it is generated by
// Http::LowerCaseString.
if (!Envoy::Http::validHeaderString(value)) {
continue;
}
Copy link
Member

Choose a reason for hiding this comment

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

Sorry in the real code where is this check done? By the codec? If this is purely for fuzzing can you potentially just guard these blocks with a FUZZ ifdef? Seems not great to add this extra runtime check where it is not needed.

Copy link
Member Author

@tyxia tyxia Feb 27, 2024

Choose a reason for hiding this comment

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

The validation in codec, for example, is http2 and http1. and I think UHV is the long-term solution to unify those validations.

I agree with undesired runtime cost (as I also mentioned it in the PR discussion :) ). Let me take another look at this. Thanks!

Copy link

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale stalebot believes this issue/PR has not been touched recently label Mar 28, 2024
Copy link

github-actions bot commented Apr 5, 2024

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot closed this Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale stalebot believes this issue/PR has not been touched recently waiting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants