Skip to content

fix: enforces request body scanning with trailers#306

Merged
jcchavezs merged 6 commits intomainfrom
fix_trailer
May 29, 2025
Merged

fix: enforces request body scanning with trailers#306
jcchavezs merged 6 commits intomainfrom
fix_trailer

Conversation

@M4tteoP
Copy link
Member

@M4tteoP M4tteoP commented May 3, 2025

Closes #289.

iosetek and others added 5 commits May 1, 2025 16:34
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.
@M4tteoP M4tteoP marked this pull request as ready for review May 3, 2025 15:09
@M4tteoP M4tteoP requested a review from jcchavezs as a code owner May 3, 2025 15:09
@M4tteoP M4tteoP mentioned this pull request May 6, 2025
@jcchavezs jcchavezs merged commit 3607c01 into main May 29, 2025
2 of 4 checks passed
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.

HTTP2 requests can bypass request payload scanning by adding request trailers

3 participants