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
Enforce Stream validity - Security Enhancement #7321
Conversation
Input parsing of incoming messages is extermely fragile, and once the pointer passed the buffer's end, the sanity check macros will return a huge size_t size instead of a negative value, thus bypassing all future checks in the code. Change the checks to use ssize_t and upon every release/free make sure that the Stream didn't reach a corrupted state. This ensures that an attacker triggering a read/write out-of-bounds will terminate the program instead of allowing the attacker to continue their exploit. Would have blocked CVE-2020-9497 (all 3 variants), CVE-2020-13396, CVE-2020-11526, CVE-2020-11088 and more.
Can one of the admins verify this patch? |
Just adding that while this is my first commit to your project, I worked with you in the past regarding several security vulnerabilities that I found in the project in 2018 and later again in 2020. This commit aims to block a vulnerability class in FreeRDP, hoping to improve the robustness of the project. |
@eyalitki nice idea, but I´d prefer the checks to stay internal to (they are only as |
Thanks for the fast response. The reason I changed the return values from The commit adds protection against very common vulnerabilities in this project as is seen from my experience of finding vulns in this project, and from vulnerabilities found by other researchers in recent years. The protection itself is divided into 2 lines of defense:
From an error handling perspective, it is easy to see that it is preferable to leverage the existing code checks & error handling instead of aborting the program for every stream that went out of bounds (assuming additional code checks are already in place and will be able to handle it gracefully). This is the goal of the first layer, and sadly the only way to achieve it is by changing the return values from I'll just add that from a compatibility point of view, this API change doesn't break the source or binary level compatibility of the project. If there are additional considerations for keeping the API unchanged, I would be happy to learn about them so I would be able to check how can this protection be redesigned to fit the requirements (if possible). Thanks again for your time. |
Seeing that #7322 handles the need to return If I'll update my PR to still include a |
Input parsing of incoming messages is extremely fragile, and once the pointer passed the buffer's end, the sanity check macros will return a huge size_t size instead of a negative value, thus bypassing all future checks in the code.
Change the checks to use ssize_t and upon every release/free make sure that the Stream didn't reach a corrupted state. This ensures that an attacker triggering a read/write out-of-bounds will terminate the program instead of allowing the attacker to continue their exploit.
Would have blocked CVE-2020-9497 (all 3 variants), CVE-2020-13396, CVE-2020-11526, CVE-2020-11088 and more.