Skip to content

uhv: header validators for H1 and H2 codecs#22537

Merged
yanavlasov merged 51 commits intoenvoyproxy:mainfrom
trail-of-forks:uhv-h1-h2-validators
Oct 11, 2022
Merged

uhv: header validators for H1 and H2 codecs#22537
yanavlasov merged 51 commits intoenvoyproxy:mainfrom
trail-of-forks:uhv-h1-h2-validators

Conversation

@ameily
Copy link
Copy Markdown
Contributor

@ameily ameily commented Aug 3, 2022

Commit Message: uhv: header validators for H1 and H2 codecs
Additional Description: This PR builds off the foundation laid in #21974 to add validators for H1 and H2. H3 and path normalization are intentionally out of scope for this PR and will be completed later.
Risk Level: Low
Testing: Build Envoy with --define uhv=enabled, configure a service with UHV enabled, and then test a valid and invalid request.

# config.yml, in the HCM section
typed_header_validation_config:
  name: envoy.http.header_validators.envoy_default
  typed_config:
      "@type": type.googleapis.com/envoy.extensions.http.header_validators.envoy_default.v3.HeaderValidatorConfig
      #
      # UHV configuration
      # uncomment any of the following:
      #
      # restrict_http_methods: true
      # reject_headers_with_underscores: true
      # http1_protocol_options: {allow_chunked_length: true}
      #

# run tests
# valid request
http GET http://localhost:10000 X-Valid:ok
# invalid request
http GET http://localhost:10000 "X Invalid":bad

Fixes #19753
Docs Changes:
Release Notes:
Platform Specific Features:

ameily added 4 commits July 29, 2022 12:10
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
Moving the call to validateHeaders fixes a segfault when validation
fails. Prior to this change, the stream would be reset after the local
reply was sent, which caused a crash. Now, the request is marked as
completed prior to sending the local reply when UHV fails.

Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @markdroth
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #22537 was opened by ameily.

see: more, trace.

@alyssawilk
Copy link
Copy Markdown
Contributor

/wait on CI

ameily added 3 commits August 4, 2022 07:59
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
@ameily
Copy link
Copy Markdown
Contributor Author

ameily commented Aug 5, 2022

@alyssawilk Can you rerun the failed CI job? CI is passing for me locally and I think the current failure is because a package couldn't be downloaded.

@alyssawilk
Copy link
Copy Markdown
Contributor

you should be able to yourself with
/retest

@repokitteh-read-only
Copy link
Copy Markdown

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

🐱

Caused by: a #22537 (comment) was created by @alyssawilk.

see: more, trace.

@kyessenov
Copy link
Copy Markdown
Contributor

/assign-from @envoyproxy/api-shepherds

@repokitteh-read-only
Copy link
Copy Markdown

@envoyproxy/api-shepherds assignee is @markdroth

🐱

Caused by: a #22537 (comment) was created by @kyessenov.

see: more, trace.

@kyessenov kyessenov assigned lizan and unassigned markdroth Aug 8, 2022
Copy link
Copy Markdown
Contributor

@yanavlasov yanavlasov left a comment

Choose a reason for hiding this comment

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

/wait

ameily added 2 commits August 12, 2022 10:11
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
@jmarantz
Copy link
Copy Markdown
Contributor

@yanavlasov @adisuissa this looks ready for another round of review.

@wrowe
Copy link
Copy Markdown
Contributor

wrowe commented Sep 19, 2022

@lizan could you give this an API stamp for the docs update?

Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Looking great! Sorry for the delay
/wait

Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
alyssawilk
alyssawilk previously approved these changes Oct 3, 2022
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk 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 the fantastic addition and all your patience with the review

yanavlasov
yanavlasov previously approved these changes Oct 5, 2022
@wrowe
Copy link
Copy Markdown
Contributor

wrowe commented Oct 6, 2022

@envoyproxy/api-shepherds - This optional validator (default, not enabled) has been approved by Yan, but who is willing to review this for an api stamp of approval?

@yanavlasov
Copy link
Copy Markdown
Contributor

I'm submitting this PR so we can proceed with follow-up work. If you have any more comments, please open Issues.

Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Thanks, left some API comments.


// Action to take when a client request with a header name containing underscore characters is received.
// If this setting is not specified, the value defaults to ALLOW.
HeadersWithUnderscoresAction headers_with_underscores_action = 4;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

High-level question: do you think there may be a need in the future for action-specific-settings.
For example, will there be something like "REPLACE_UNDERSCORE" that will need the replacement string.
If so, I would suggest using a oneof, and messages for each option.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All these settings are for existing behavior. In the future if people want to modify it, they can add a new extension with their own config.


// Action to take when a client request with a header name containing underscore characters is received.
// If this setting is not specified, the value defaults to ALLOW.
HeadersWithUnderscoresAction headers_with_underscores_action = 4;
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.

Does this field need an Envoy build with uhv=enabled to take effect? If so please document.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

UHV is enabled in HCM

which is currently marked as hidden.

The uhv=enabled is really a temporary build flag to safely transition to the new verification code. Do you think we need to document it? It will not be added into the generated documentation anyway because of the hidden flag.

Signed-off-by: Adam Meily <adam.meily@trailofbits.com>
@ameily ameily dismissed stale reviews from yanavlasov and alyssawilk via 42251ef October 11, 2022 17:13
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

/lgtm api

@yanavlasov
Copy link
Copy Markdown
Contributor

Looks like all comments were addressed. If we missed anything, please file an Issue and we will address in a followup PR.

@yanavlasov yanavlasov merged commit 05360a8 into envoyproxy:main Oct 11, 2022
phlax pushed a commit to phlax/envoy that referenced this pull request Jun 26, 2023
Signed-off-by: Adam Meily <adam.meily@trailofbits.com>

Signed-off-by: Adam Meily <ameily@users.noreply.github.com>

Signed-off-by: Ryan Northey <ryan@synca.io>
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.

uhv: implement default protocol header validations