fix: enforces request body scanning with trailers#306
Merged
Conversation
The present implementation of WASM plugin is missing a scenario that onRequestBody method will never be called with end_of_stream parameter set to true. Such situation will happen for HTTP 2 request with trailers as the presence of trailers means that the last chunk of payload is still not the end of the request stream. This is problematic because existing implementation triggers threat scanning when onRequestBody is called with parameter end_of_stream set to true as it was expected to be a proper place: * right after collecting entire payload * before completing the request stream This is true only for scenarios that do NOT include request trailers (unless it is HTTP1 as Envoy Proxy ignores request trailers for that protocol - the explanation is that trailers in HTTP1 are very often not handled properly by various servers even though HTTP standard allows it). To fix it, onRequestTrailers method was implemented to cover the situation when request payload was collected as onRequestTrailers is the method which applies to the situation: * right after collecting entire payload * before completing the request stream To maintain the existing logic, this method calls onRequestBody with end_of_stream set to true, to share the same logic. The onResponseTrailers method was not implemented but perhaps it should be implemented as well.
Closed
jcchavezs
approved these changes
May 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #289.
1.23.8