Skip to content

aws_request_signing: a few fixes - #10280

Merged
mattklein123 merged 9 commits into
envoyproxy:masterfrom
rgs1:aws-request-signing-fixes
Mar 9, 2020
Merged

mattklein123 merged 9 commits into
envoyproxy:masterfrom
rgs1:aws-request-signing-fixes

Conversation

@rgs1

@rgs1 rgs1 commented Mar 6, 2020 •

Copy link
Copy Markdown
Member

There were a few things missing to make this filter work with S3:

  • empty body requests (e.g.: GET) still need a sha256 content header
    (the empty string hash)
  • requests for s3 shouldn't sign all headers (especially because some
    of them might change, e.g.: x-forwarded-for)
  • when proxying requests to s3, HCM's host rewrite won't work so
    support it as a filter config option
  • ditto for prefix rewrite [ not supported yet ]

Signed-off-by: Raul Gutierrez Segales [email protected]

There were a few things missing to make this filter work with S3:

* empty body requests (e.g.: GET) still need a sha256 content header
  (the empty string hash)
* requests for s3 shouldn't sign all headers (especially because some
  of them might change, e.g.: x-forwarded-for)
* when proxying requests to s3, HCM's host rewrite won't work so
  support it as a filter config option
* ditto for prefix rewrite

Signed-off-by: Raul Gutierrez Segales <[email protected]>
@rgs1
rgs1 requested a review from mattklein123 as a code owner March 6, 2020 01:22
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.

🐱

Caused by: #10280 was opened by rgs1.

see: more, trace.

@rgs1

rgs1 commented Mar 6, 2020

Copy link
Copy Markdown
Member Author

cc: @lavignes @marcomagdy

Raul Gutierrez Segales added 2 commits March 5, 2020 23:01
Signed-off-by: Raul Gutierrez Segales <[email protected]>
Signed-off-by: Raul Gutierrez Segales <[email protected]>
@marcomagdy

marcomagdy commented Mar 6, 2020 •

Copy link
Copy Markdown
Contributor

seems like some changes overlap with the Lambda PR I submitted yesterday...

I think there are a couple of things we both agree on:

  • Avoid signing x-forwarded-proto
  • Use the empty content hash if none was provided. (for S3, I'm pretty sure the value of the hash should be the literal UNSIGNED_PAYLOAD )
  • I had to update the unit tests because the hash changed now that we're always using the empty hash if none is provided.

@rgs1

rgs1 commented Mar 6, 2020

Copy link
Copy Markdown
Member Author

/retest

@repokitteh-read-only

Copy link
Copy Markdown

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #10280 (comment) was created by @rgs1.

see: more, trace.

@dio

dio commented Mar 6, 2020

Copy link
Copy Markdown
Member

@rgs1 "coverage" is currently not working.

Comment thread source/extensions/common/aws/utility.cc Resolved
Comment thread source/extensions/common/aws/utility.cc Resolved
@marcomagdy

Copy link
Copy Markdown
Contributor

Spoke privately with @rgs1 and we decided to:

  • Blacklist x-forwarded-for and x-forwarded-proto in the signer, since they do mutate in our experience. And it's better to sign as many headers as possible for security and for compatibility with all AWS services.
  • Use UNSIGNED_PAYLOAD for S3 payloads only.
  • host_rewrite is needed because in S3's case the bucket name is part of the domain.
  • prefix_rewrite is needed for flexibility of URLs in general
  • We need a per_filter_config for this filter.

Raul Gutierrez Segales added 2 commits March 6, 2020 19:30
These two are most likely to mutate, everything else is allowed.

Signed-off-by: Raul Gutierrez Segales <[email protected]>
Signed-off-by: Raul Gutierrez Segales <[email protected]>
@rgs1

rgs1 commented Mar 6, 2020

Copy link
Copy Markdown
Member Author

Spoke privately with @rgs1 and we decided to:

  • Blacklist x-forwarded-for and x-forwarded-proto in the signer, since they do mutate in our experience. And it's better to sign as many headers as possible for security and for compatibility with all AWS services.
  • Use UNSIGNED_PAYLOAD for S3 payloads only.
  • host_rewrite is needed because in S3's case the bucket name is part of the domain.
  • prefix_rewrite is needed for flexibility of URLs in general
  • We need a per_filter_config for this filter.

Thanks for the summary; handled all except:

  1. prefix_rewrite (will push commits for that later this weekend or on Mon)
  2. per_filter_config support, since I want to tackle that via make per_filter_config specific configs work automatically for filters #10164

Signed-off-by: Raul Gutierrez Segales <[email protected]>
@mattklein123 mattklein123 self-assigned this Mar 9, 2020
@rgs1

rgs1 commented Mar 9, 2020

Copy link
Copy Markdown
Member Author

/retest

@repokitteh-read-only

Copy link
Copy Markdown

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #10280 (comment) was created by @rgs1.

see: more, trace.

@rgs1

rgs1 commented Mar 9, 2020

Copy link
Copy Markdown
Member Author

Spoke privately with @rgs1 and we decided to:

  • Blacklist x-forwarded-for and x-forwarded-proto in the signer, since they do mutate in our experience. And it's better to sign as many headers as possible for security and for compatibility with all AWS services.
  • Use UNSIGNED_PAYLOAD for S3 payloads only.
  • host_rewrite is needed because in S3's case the bucket name is part of the domain.
  • prefix_rewrite is needed for flexibility of URLs in general
  • We need a per_filter_config for this filter.

Thanks for the summary; handled all except:

  1. prefix_rewrite (will push commits for that later this weekend or on Mon)
  2. per_filter_config support, since I want to tackle that via make per_filter_config specific configs work automatically for filters #10164

I don't actually need prefix_rewrite (which needs per_filter_config) immediately, so that can happen in a follow-up PR.

cc: @marcomagdy

marcomagdy
marcomagdy previously approved these changes Mar 9, 2020

@marcomagdy marcomagdy left a comment

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.

LGTM. There's one optimization that I think is worth it though.
Thank you!

Signed-off-by: Raul Gutierrez Segales <[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.

Thanks!

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.

4 participants