envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.97k stars 4.81k forks source link

Wired usage of continueDecoding in BandwidthLimiter #36555

Open spacewander opened 3 weeks ago

spacewander commented 3 weeks ago

If you are reporting any crash or any potential security issue, do not open an issue in this repo. Please report the issue via emailing envoy-security@googlegroups.com where the issue will be triaged appropriately.

Title: One line description

Wired usage of continueDecoding in BandwidthLimiter

Description:

Describe the issue.

The bandwidthLimiter will call continueDecoding when it wants to continue processing the trailers. See https://github.com/envoyproxy/envoy/blob/bb28dda78d462851c1810047a4b1488a5a69279a/source/extensions/filters/http/bandwidth_limit/bandwidth_limit.cc#L85-L98

https://github.com/envoyproxy/envoy/blob/bb28dda78d462851c1810047a4b1488a5a69279a/source/extensions/filters/http/common/stream_rate_limiter.h#L43

And the continueDecoding requires the decodeHeaders() to return StopIteration: https://github.com/envoyproxy/envoy/blob/bb28dda78d462851c1810047a4b1488a5a69279a/envoy/http/filter.h#L535-L545

However, the decodeHeaders() of bandwidthLimiter only returns Http::FilterHeadersStatus::Continue: https://github.com/envoyproxy/envoy/blob/bb28dda78d462851c1810047a4b1488a5a69279a/source/extensions/filters/http/bandwidth_limit/bandwidth_limit.cc#L111

Is the usage of continueDecoding safe in BandwidthLimiter?

tyxia commented 3 weeks ago

Add @nezdolik is driving the effort of fixing misuse of continue{De/En}coding. We are still discussing the API check that is under review.

But, I don't think bandwidth filter is tagged as misused filter even in current API check

nezdolik commented 1 week ago

The api check currently only verifies the contineEncoding/Decoding()->commonContinue() path.

nezdolik commented 1 week ago

It is not 100% safe but one needs to come up an example of filterchain config that results into filterchain/data processing weirdness due to api misuse (like double processing of data or filters being skipped etc). One similar example here: https://github.com/envoyproxy/envoy/issues/22064