Skip to content

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

Merged
mattklein123 merged 5 commits intoenvoyproxy:masterfrom
rgs1:csrf-fixes
Jul 17, 2020
Merged

csrf: fix issues with host/origin header parsing#12133
mattklein123 merged 5 commits intoenvoyproxy:masterfrom
rgs1:csrf-fixes

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 rgs@pinterest.com

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 <rgs@pinterest.com>
Signed-off-by: Raul Gutierrez Segales <rgs@pinterest.com>
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 <rgs@pinterest.com>
@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 <rgs@pinterest.com>
Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
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 <rgs@pinterest.com>
Signed-off-by: scheler <santosh.cheler@appdynamics.com>
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