connection: don't pass read data to filters when in delayed close.#6852
connection: don't pass read data to filters when in delayed close.#6852htuch merged 6 commits intoenvoyproxy:masterfrom
Conversation
Fuzzing revealed that HCM is not happy when it think it has performed a close(), e.g. due to CodecProtocolException, and new data arrives in onData(). It basically tries to dispatch that to the codec, which might be in reset state. This situation can arise when the connection (at the network level) is in delayed close and it continues to dispatch to HCM. The fix is to not forward data in ConnectionImpl::onRead(). This seems the safest place to short circuit during delayed close, since L4 filters (including HCM) should be able to rely on the fact that they don't receive any data after a close(). Fixes oss-fuzz issue https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14516. Risk level: Medium (one line change, sensitive area of code base) Testing: TBD Signed-off-by: Harvey Tuch <htuch@google.com>
|
@AndresGuedez @alyssawilk @mattklein123 LMK if you think this is the right approach and I'll add some tests beyond the corpus entry. There's actually a bunch of bad stuff that happens in HCM if you pump in data after it thinks it has closed; I think other L4 filters could also suffer from this. |
AndresGuedez
left a comment
There was a problem hiding this comment.
Thanks for looking into this. I suggested an alternate approach to your fix which avoids the extra conditional.
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
alyssawilk
left a comment
There was a problem hiding this comment.
Though optional (me being me) I'd love an addition to unit tests as well as the fuzz test :-)
mattklein123
left a comment
There was a problem hiding this comment.
Definitely looks like the right approach.
/wait
Signed-off-by: Harvey Tuch <htuch@google.com>
bdcc185 to
06d8363
Compare
mattklein123
left a comment
There was a problem hiding this comment.
Thanks, this looks like a solid fix. Would definitely like @AndresGuedez and @alyssawilk to take a look.
There was a problem hiding this comment.
Thanks for all the extra test coverage!
A few general comments regarding the tests:
- I think it would be helpful to
EXPECT_CALL(.., closeSocket(...))since the socket's state explains whytransport_socket_->doRead()does or does not trigger in the tests. transport_socket_->canFlushClose()is returningfalsewhich means that some corner cases regarding write buffers not being depleted after writes are not being exercised. Consider adding a test to cover that edge case.
alyssawilk
left a comment
There was a problem hiding this comment.
LGTM pending Andres' comments being addressed
Signed-off-by: Harvey Tuch <htuch@google.com>
…nvoyproxy#6852) Fuzzing revealed that HCM is not happy when it think it has performed a close(), e.g. due to CodecProtocolException, and new data arrives in onData(). It basically tries to dispatch that to the codec, which might be in reset state. This situation can arise when the connection (at the network level) is in delayed close and it continues to dispatch to HCM. The fix is to not forward data in ConnectionImpl::onRead(). This seems the safest place to short circuit during delayed close, since L4 filters (including HCM) should be able to rely on the fact that they don't receive any data after a close(). Fixes oss-fuzz issue https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14516. Risk level: Medium (one line change, sensitive area of code base) Testing: Unit tests added. Signed-off-by: Harvey Tuch <htuch@google.com> Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Fuzzing revealed that HCM is not happy when it think it has performed a
close(), e.g. due to CodecProtocolException, and new data arrives in
onData(). It basically tries to dispatch that to the codec, which might
be in reset state. This situation can arise when the connection (at the
network level) is in delayed close and it continues to dispatch to HCM.
The fix is to not forward data in ConnectionImpl::onRead(). This seems
the safest place to short circuit during delayed close, since L4 filters
(including HCM) should be able to rely on the fact that they don't
receive any data after a close().
Fixes oss-fuzz issue
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14516.
Risk level: Medium (one line change, sensitive area of code base)
Testing: Unit tests added.
Signed-off-by: Harvey Tuch htuch@google.com