Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large request payload makes geoip filter wrongly trim decodeData #33021

Closed
JuniorHsu opened this issue Mar 21, 2024 · 4 comments · Fixed by #33122
Closed

Large request payload makes geoip filter wrongly trim decodeData #33021

JuniorHsu opened this issue Mar 21, 2024 · 4 comments · Fixed by #33122
Labels
area/geoip Any work related to geoip filter bug

Comments

@JuniorHsu
Copy link
Contributor

Title: Large request payload makes geoip filter wrongly trim decodeData

Description:
While request payload is large, the upstream service could received truncated bytes, i.e., the remaining filters behind geoip could miss somedecodeData events.

Here's what we think:
While the filter does async lookup, it asks filter manager to stop iteration but not stop the world.

return Http::FilterHeadersStatus::StopIteration;

However, decodeDatas probably come after and we return Continue

return Http::FilterDataStatus::Continue;

by the comments which unlock decodeHeaders to the remaining filters

// will be sent first via decodeHeaders()/encodeHeaders(). If data has previously been buffered,

Therefore, we have two side effect
(a) the header is not set before decodeData sent out

request_headers_->setCopy(Http::LowerCaseString(geo_header), lookup_result);

(b) while we code continueDecoding again, filter manager fails to handle the events correctly, which triggers the bug we observed.

decoder_callbacks_->continueDecoding();

Un-equipping geoip filter resolved the issue.

--

So we have two bugs I think
(i)

return Http::FilterHeadersStatus::StopIteration;

we should use StopAllIterationAndWatermark in geoip filter to stop the world so we could set headers ready

(ii) although this might be only side effect of filter event mishandling but continueDecoding could make the data truncated and IIRC this is not the first time we hit the similar issue. Might need filter management expert to weigh in.

@JuniorHsu JuniorHsu added bug triage Issue requires triage labels Mar 21, 2024
@htuch
Copy link
Member

htuch commented Mar 22, 2024

@htuch htuch added area/geoip Any work related to geoip filter and removed triage Issue requires triage labels Mar 22, 2024
@JuniorHsu
Copy link
Contributor Author

we've verified that StopAllIterationAndWatermark work as expected

@alyssawilk
Copy link
Contributor

yeah that sounds like a reasonable fix to me. cc @nezdolik @ravenblackx as geoip owners.

@JuniorHsu
Copy link
Contributor Author

cool we can work on a patch and let's go from there. thanks alyssa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/geoip Any work related to geoip filter bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants