-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Zlib: Add some protections to the allocator used by zlib #84604
Conversation
Tagging subscribers to this area: @dotnet/area-system-io-compression Issue DetailsThis adds defense-in-depth protections to the allocator used by zlib to help mitigate the risk posed by potential future CVEs against this library. Basic defenses against use-of-uninitialized-memory bugs, local buffer overruns, and double-free bugs are provided. The overall goal is that should a future CVE be found that fits one of those categories, the CVE's nominal severity can drop from Critical -> Important or from Important -> Moderate because of the difficulty of successful exploit. The .c files included in this PR describe the defenses in more detail. Windows benchmark results:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we can have tests that verify this new code?
@carlossanlop I'm open to suggestions as to how to test this! The most straightforward way that occurs to me is to have a callback mechanism, but now we're leaking abstractions through the DLL's exports and inserting complexity. :( |
do you plan to offer these to zlib upstream? |
No. Per our other conversation, I don't think it's necessary. |
I also reran the aspnet benchmarks after ripping out the LFH code and didn't observe any difference before + after the change. |
- Move allocator files under Compression.Native dir - Update pal_zlib includes, use calloc instead of malloc - Remove custom typedefs from zlib unix allocator
High level notes from the latest iteration:
I smoke tested the Unix version on my Ubuntu box by making a change to cmakelists.txt and forcing us to use the internal version, even though the distro already had a shared zlib library. New test run since the other one went stale: https://dev.azure.com/dnceng-public/public/_build/results?buildId=246796 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change. And thanks for all the comments, they were quite helpful.
/backport to release/7.0-staging |
Started backporting to release/7.0-staging: https://github.com/dotnet/runtime/actions/runs/5674150369 |
This adds defense-in-depth protections to the allocator used by zlib to help mitigate the risk posed by potential future CVEs against this library. Basic defenses against use-of-uninitialized-memory bugs, local buffer overruns, and double-free bugs are provided. The overall goal is that should a future CVE be found that fits one of those categories, the CVE's nominal severity can drop from Critical -> Important or from Important -> Moderate because of the difficulty of successful exploit.
The .c files included in this PR describe the defenses in more detail.
Windows benchmark results:
Though the three PRs #84602, #84603, and #84604 are all related to zlib; they're each fully standalone and can be reviewed as isolated units.