-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[postgres_proxy] assert failure with untrusted buffer when onData() #12340
Comments
Hi @jianwen612, thanks for testing it... I totally agree with And just 5 bytes is enough to throw exception:
LGTM |
I agree that adding @jianwen612 Thanks for testing it. Making this filter to pass fuzz testing requires more changes. I will address this issue in few weeks, as I will be away. |
Thanks for pointing this out! |
Thank you for sharing this! Okey, then I will temporarily disable the fuzzing for this filter. |
/assign @cpakulski |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions. |
WIP. |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions. |
WIP. |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions. |
Is this still a work-in-progress? |
@rostams-lyft Yes, I am still working on it. |
Switch to cpakuslki/envoy repo to check issue envoyproxy/envoy#12340
@jianwen612 I opened a PR #16575 to fix this issue. Can you help me verify that fuzz tests do not crash the postgres filter? Thanks! |
Sorry... I don't have the environment to test it now. I've moved to another team. |
Commit Message: Validate postgres messages before parsing. Additional Description: Introduced InSync and OutOfSync states in decoder. When decoder detects a wrongly formatted message, it stops parsing and moves to OutOfSync state. Continuing parsing after encountering message with wrong syntax may lead to interpreting random bytes as length of the message and possibly causing OOM. Risk Level: Low Testing: Added unit tests and run full regression tests. Docs Changes: No. Release Notes: No. Platform Specific Features: Fixes #12340 Signed-off-by: Christoph Pakulski <[email protected]>
Commit Message: Validate postgres messages before parsing. Additional Description: Introduced InSync and OutOfSync states in decoder. When decoder detects a wrongly formatted message, it stops parsing and moves to OutOfSync state. Continuing parsing after encountering message with wrong syntax may lead to interpreting random bytes as length of the message and possibly causing OOM. Risk Level: Low Testing: Added unit tests and run full regression tests. Docs Changes: No. Release Notes: No. Platform Specific Features: Fixes envoyproxy#12340 Signed-off-by: Christoph Pakulski <[email protected]>
I'm currently working on fuzz test(which generates random bytes for onData() and onWrite() to see whether we could crash the Envoy) for network-level filters.
When I was testing on postres_proxy filter with some untrusted data, an assert failure occurred inside linearize:
RELEASE_ASSERT(size <= length(), "Linearize size exceeds buffer size");
https://github.com/envoyproxy/envoy/blob/master/source/extensions/filters/network/postgres_proxy/postgres_decoder.cc#L201
This error only happens in fuzzer or when upstream server is on bad state, so it is not security-critical now.
But I think that we could deal with this error more gracefully. (So that we could make the filter more robust to upstream errors, and enable the fuzzer to continue testing it).
My idea is that we could make it just like other invalid error handles in this file, which is
return false;
, before calling linearize?This solution looks like this(from line 200):
This issue can be reproduced in unit test by adding a case as below(test/extensions/filters/network/postgres_proxy/postgres_decoder_test.cc):
If anyone has a better idea, please share with me or make a pull request and link it here. Thanks!
/cc @dio
/cc @fabriziomello
/cc @cpakulski
The text was updated successfully, but these errors were encountered: