Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tools] Surround mbedTLS's CTR_DRBG operations with spinlocks
mbedTLS explicitly says that CTR_DRBG operations are not thread-safe. Previously, our Protected Files utility code (currently used only for the `gramine-sgx-pf-crypt` tool) was rendered thread-unsafe because it used CTR_DRBG without any synchronization (note that we do not build mbedTLS with `MBEDTLS_THREADING_C`). This was not a security issue in Gramine because the only user (`gramine-sgx-pf-crypt`) is single-threaded, but it is a potential vulnerability if this utility code is reused in some other, multi-threaded scenarios. To make CTR_DRBG thread-safe, this commit surrounds the relevant logic with spinlocks. The only identified mbedTLS function that needs this is `mbedtls_ctr_drbg_random()`. See also mbedTLS docs. Kudos to Petr Evstifeev (Villain88) who reported this issue. Signed-off-by: Dmitrii Kuvaiskii <[email protected]>
- Loading branch information