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

csrf: fix issues with host/origin header parsing #12133

Merged
merged 5 commits into from
Jul 17, 2020

Conversation

rgs1
Copy link
Member

@rgs1 rgs1 commented Jul 16, 2020

Commit Message: csrf: fix issues with host/origin header parsing

Additional Description:

After #11670, the CSRF filter started failing for us.

This change fixes 3 issues that were uncovered after moving
to gURL for parsing URLs:

  1. the hostAndPort() utility method, in the CSRF filter, was
    returning a string view of a stack variable.

  2. the Origin header always includes the scheme, so let's ensure
    this is exercised in tests (which were missing this and passing
    due to relaxed checks).

  3. the Url::initialize method expects an absolute URL, something that
    the CSRF filter wasn't complying with when parsing the Host header.

Risk Level: low
Testing: changed/added
Docs Changes: none
Release Notes: added

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

After envoyproxy#11670, the CSRF filter started failing for us.

This change fixes 3 issues that were uncovered after moving
to gURL for parsing URLs:

1) the hostAndPort() utility method, in the CSRF filter, was
returning a string view of a stack variable.

2) the Origin header always includes the scheme, so let's ensure
this is illustrated in tests (which were missing this and passing
due to relaxed checks).

3) the Url::initialize method expects an absolute URL, something that
the CSRF filter wasn't complying with.

Signed-off-by: Raul Gutierrez Segales <[email protected]>
Signed-off-by: Raul Gutierrez Segales <[email protected]>
Two things were missing:

* the origin/referer headers in the integration test needed
  their respective schemes.
* for some reason, headers.Scheme() is nullptr during integration
  tests... Hmm, not sure why.

Signed-off-by: Raul Gutierrez Segales <[email protected]>
@mattklein123 mattklein123 merged commit f84dd5c into envoyproxy:master Jul 17, 2020
KBaichoo pushed a commit to KBaichoo/envoy that referenced this pull request Jul 30, 2020
After envoyproxy#11670, the CSRF filter started failing for us.

This change fixes 3 issues that were uncovered after moving
to gURL for parsing URLs:

1) the hostAndPort() utility method, in the CSRF filter, was
returning a string view of a stack variable.

2) the Origin header always includes the scheme, so let's ensure
this is illustrated in tests (which were missing this and passing
due to relaxed checks).

3) the Url::initialize method expects an absolute URL, something that
the CSRF filter wasn't complying with.

Signed-off-by: Raul Gutierrez Segales <[email protected]>
Signed-off-by: Kevin Baichoo <[email protected]>
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
After envoyproxy#11670, the CSRF filter started failing for us.

This change fixes 3 issues that were uncovered after moving
to gURL for parsing URLs:

1) the hostAndPort() utility method, in the CSRF filter, was
returning a string view of a stack variable.

2) the Origin header always includes the scheme, so let's ensure
this is illustrated in tests (which were missing this and passing
due to relaxed checks).

3) the Url::initialize method expects an absolute URL, something that
the CSRF filter wasn't complying with.

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

3 participants