Support using the system version of brotli (#66462)
authorOmair Majid <omajid@redhat.com>
Wed, 23 Mar 2022 03:49:50 +0000 (23:49 -0400)
committerGitHub <noreply@github.com>
Wed, 23 Mar 2022 03:49:50 +0000 (20:49 -0700)
commit5ca9223639700750ff12bb1fed9fa6e397062b78
tree4f2a665450f82e223f5489c1274f739990f26a30
parentc3e1d21c2fb30436ae24ef7ef4f458e3270bb7e3
Support using the system version of brotli (#66462)

This is mainly motivated by the March 2022 release of .NET 5. .NET 5 was
found to be vulnerable to CVE-2020-8927, which was caused by the older
version of brotli built into .NET. .NET was vulernable even in
environments where a system-wide version of brotli was present and had
already received fixes for this CVE. We could have avoided a Remote Code
Execution vulnerability in such environments by using the system's
version of brotli.

This is similar to the existing support for disabling distro-agnostic
OpenSSL (except no OpenSSL is embedded) and using the system libunwind
(a copy of libunwind is embedded this repo).

One small twist is the presence of entrypoint verification. In a
system-brotli build, the verification fails, because the built library,
libSystem.IO.Compression.Native.so, doesn't include the symbols for
Brotli. Those symbols are instead used from the system brotli libraries.
src/native/external/brotli.cmake
src/native/libs/System.IO.Compression.Native/CMakeLists.txt
src/native/libs/System.IO.Compression.Native/entrypoints.c
src/native/libs/System.IO.Compression.Native/extra_libs.cmake