You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because calls to the CPUID instruction must take place in untrusted memory, the results of CPUID cannot be trusted! This warning applies whether you run CPUID yourself or rely on the SGX functions to do it for you. The Intel SGX SDK offers this advice: “Code should verify the results and perform a threat evaluation to determine the impact on trusted code if the results were spoofed.”
It goes onto suggest that in a secure RNG design,
RDRAND is detected, but a negative result is spoofed. This will result in an error at runtime, causing the program to exit gracefully since a required feature is not detected.
However, the code in question does not raise a runtime error, but rather quite fantastically makes this mistake:
It appears to fallback to stdlib's rand() if the untrusted cpuid call says rdrand is not supported, which means that sgx_read_rand will fail to deliver good randomness.
In this file, as of writing, you appear to determine whether or not rdrand is supported like this:
However, CPUID is not allowed to be trusted inside SGX, per this documentation:
It goes onto suggest that in a secure RNG design,
However, the code in question does not raise a runtime error, but rather quite fantastically makes this mistake:
It appears to fallback to stdlib's
rand()
if the untrusted cpuid call says rdrand is not supported, which means thatsgx_read_rand
will fail to deliver good randomness.It looks like other Intel code, such as the recent work porting OpenSSL to SGX, relies on that function returning cryptographically secure random numbers:
https://github.com/01org/intel-sgx-ssl/blob/master/sgx/libsgx_tsgxssl/trand.cpp#L51
https://github.com/01org/intel-sgx-ssl/blob/master/openssl_source/rand_unix.c#L44
https://github.com/01org/intel-sgx-ssl/blob/master/openssl_source/md_rand.c#L61
The text was updated successfully, but these errors were encountered: