Only proxy some headers from the reply in MTBroker filter#6357
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aliok The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold @knative/security-wg-leads @evankanderson @rhuss Can you think of any other headers that we shouldn't proxy? |
|
/cherrypick release-1.4 |
|
@aliok: once the present PR merges, I will cherry-pick it on top of release-1.4 in a new PR and assign it to you. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/cherrypick release-1.3 |
|
@aliok: once the present PR merges, I will cherry-pick it on top of release-1.3 in a new PR and assign it to you. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/cherrypick release-1.2 |
|
@aliok: once the present PR merges, I will cherry-pick it on top of release-1.2 in a new PR and assign it to you. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Codecov Report
@@ Coverage Diff @@
## main #6357 +/- ##
=======================================
Coverage 82.39% 82.40%
=======================================
Files 233 233
Lines 11567 11572 +5
=======================================
+ Hits 9531 9536 +5
Misses 1573 1573
Partials 463 463
Continue to review full report at Codecov.
|
|
/test upgrade-tests_eventing_main |
|
/test upgrade-tests_eventing_main Flake? |
|
cc @evankanderson |
|
I'd suggest an opposite approach of extracting a CloudEvent from the HTTP response, rather than attempting to handle HTTP headers being the CloudEvents spec. (Will look at the PR contents shortly.) In general, attempting a blocklist approach to validation is a pattern that's associated with surprising security vulnerabilities. The |
|
Thanks for the feedback @evankanderson
Any headers with
We could have an allow-list then :) I don't want to go into making this allow-list configurable (e.g. via configmap or something similar) for now. Any feedback would be appreciated before I go and modify my PR. |
|
I 100% agree on not making the allow-list configurable. This is part of the "delivery contract", so any additional headers that we interpret outside of CloudEvents should be documented somewhere, and not just a willy-nilly repetition. |
|
In this particular case I think we want a block-list to allow custom headers to pass-through, and we should audit which standardized HTTP headers need to be filtered out. |
f847a77 to
1e261aa
Compare
|
Question: why do we need / want a block-list here? If I introduce a new header, or include a header in my reply which is only specified for requests (for example |
|
Comparing the behaviour previous to #5946, I think having an allow-list for now is the minimal change we can do to make things working without any big impact. I prefer going this route and seeing if there's any feedback from the community around other headers. |
|
This change seems to be an improvement, though I'd still prefer to see an allow-list of pass-through headers. For clarity / posterity, this is at the following location ( The goal is to be able to leverage delivery contract extensions by simply proxying through delivery contract headers to the Channel implementation. I'm presuming that the problem is that we don't have a map/StringSet of the known delivery headers at the moment, so it's hard to build the allow-list. It also means that experimental delivery contract headers which are implemented in a single out-of-core channel need a change in the core in order to work with the MT Broker. |
This is the allow-list: https://github.com/knative/eventing/pull/6357/files#diff-f2e0f39d7130b2386e41c21acc3e30d1ce6a37f44c11e81388825f6094af0306R62-R65
Yes.
This is also true. Thanks for pointing that out. Updating the release note for the PR now. At the very least, I tested the change with KafkaChannel and it works fine :) I won't be able to test other channel implementations.
Do we know which channel implementations are those? cc @lionelvillard maybe you know? |
|
Oh, BTW, this proxying feature is added with #5946 in Dec 2021. So, it hasn't been too much time that would allow channel implementors to rely on the proxy-everything approach to implement experimental delivery contract headers. |
|
/hold I asked in the dev mailing list if there are any channel implementors who rely on proxying all headers: https://groups.google.com/g/knative-dev/c/R7uUCJuZE50 Even if you think we're all good to merge, I will still wait for a week before I merge this to allow people to shout. |
|
I misunderstood the allow-list is only about HTTP headers, not CloudEvents attributes. Got that mixed up. @aliok feel free to uphold whenever you are ready. |
|
This PR was discussed in the last WG, and we agreed on having the allowlist since the functionality of proxying headers was introduced as part of the (still) experimental Retry-After feature. |
|
If we will have more use-cases that want to proxy arbitrary headers we can always introduce a more extensible solution. |
Sorry, I hadn't seen the earlier rewrite. I'm happy with the allow-list for now. I was just trying to understand the risk / danger / problem with the allowlist, and the tradeoff is that extending the delivery contract requires extending the "allowed-to-proxy-headers" list. That seems reasonable on the face of it; if we discover this is a problem, we can discuss how to configure this (global configmap, subscription status, etc) then. I'm in favor of this. /lgtm |
|
|
||
| // HeaderProxyAllowList contains the headers that are proxied from the reply; other than the CloudEvents headers. | ||
| // Other headers are not proxied because of security concerns. | ||
| var HeaderProxyAllowList = map[string]struct{}{ |
There was a problem hiding this comment.
This is fine. As an FYI, Kubernetes has some helpers here: https://pkg.go.dev/k8s.io/apimachinery/pkg/util/sets#String
There will probably be an equivalent for go 1.19 or so with generics, I expect.
|
@aliok: new pull request created: #6386 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
@aliok: new pull request created: #6387 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
@aliok: new pull request created: #6388 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Fixes: #6276
Related: knative-extensions/eventing-kafka-broker#2122
Multiple
Content-Lengthheaders were set when there's a reply used.Specifically, we added support for proxying headers from replies here: #5946
However, not every header is good for proxying.
One example is
Content-Length. Having multipleContent-Lengthheaders somehow exploitable (not a security expert here).This PR prevents having multiple
Content-Lengthheaders. There might be other headers that we shouldn't proxy. I will ask this in a PR comment.This is very hard to test because when I tell the mock http server to send a specific
Content-Lengthwith the reply for checking, it responds with502. However, we tested it at eventing-kafka-broker repository and it fixes the issue there.Proposed Changes
Content-Lengthheaders from replies anymore. Instead, it computes on its own.Pre-review Checklist
Release Note
Docs