Monorail Project: project-zero Issues People Development process History Sign in
New issue
Advanced search Search tips
Starred by 4 users
Status: Fixed
Owner:
Closed: Jan 2017
Cc:



Sign in to add a comment
Samsung: Stack buffer overflow and information disclosure in OTP TrustZone trustlet via OTP_GET_CRYPTO_DERIVED_KEY
Project Member Reported by laginimaineb@google.com, Sep 13 2016 Back to list
As a part of the KNOX extensions available on Samsung devices, Samsung provides a TrustZone trustlet which allows the generation of OTP tokens.

The tokens are generated in a TrustZone application within the TEE (UID: fffffffff0000000000000000000001e), which can be communicated with using the "OTP" service, published by "otp_server".

The command "OTP_GET_CRYPTO_DERIVED_KEY" allows the user to generate a key using a KDF which is based on a previously unwrapped OTP token. However, after unwrapping the supplied OTP token, the command fails to validate the derived key length field (at offset 1128 in the request buffer). This argument is then passed on to the KDF, and may be arbitrarily large.

Supplying a large value for the derived key length field will cause the KDF function to overwrite the destination buffer with the derived key bytes. As the destination buffer in located on the stack, this will allow the attack to overwrite important stack data.

Since HMAC-SHA1/HMAC-SHA256 are PRFs and the password in the token is unknown to the attacker, this issue would be harder to exploit on its own (would require to blindly brute-force the destination bytes). However, the "otp_get_crypto_derived_key" function also contains an information disclosure vulnerability that would allow the attacker to leak the derived key for each attempt.

After calling the KDF, the aforementioned length field is used as the length argument in a "memcpy" call which copies the generated bytes into the user's response buffer, thus leaking the generated bytes back to the Non-Secure World.

This bug is subject to a 90 day disclosure deadline. If 90 days elapse
without a broadly available patch, then the bug report will automatically
become visible to the public.

 
Project Member Comment 1 by laginimaineb@google.com, Dec 12 2016
Labels: -Restrict-View-Commit Deadline-Exceeded
Status: Started
Samsung has started rolling out the fix this month. Deadline exceeded -- automatically derestricting.
Project Member Comment 2 by laginimaineb@google.com, Dec 31 2016
Labels: SVE-2016-7174
Project Member Comment 3 by laginimaineb@google.com, Jan 3 2017
Status: New
Newest version (G925VVRU4CPK2_G925VVZW4CPK2_VZW) remains unpatched.
Project Member Comment 4 by laginimaineb@google.com, Jan 4 2017
Status: Fixed
G925VVRU4CPK2_G925VVZW4CPK2_VZW was on the November SMR -- verified fix on G930FXXU1BPLB_G930FUUB1BPL4_UPO.
Project Member Comment 5 by laginimaineb@google.com, Feb 3 2017
Summary: Samsung: Stack buffer overflow and information disclosure in OTP TrustZone trustlet via OTP_GET_CRYPTO_DERIVED_KEY (was: Stack buffer overflow and information disclosure in OTP TrustZone trustlet via OTP_GET_CRYPTO_DERIVED_KEY)
Sign in to add a comment