Researchers in Tel Aviv have found a security vulnerability which affect Samsung smartphones including the Galaxy S series. Android smartphones have any number of sensitive use cases, such as paying for services with Google Pay, logging in to web services, and online banking. To safeguard these kinds of transactions, Android smartphones running on ARM architecture use a separate execution environment for security-sensitive functions. This environment, known as the TrustZone Execution Environment, runs a separate OS, TrustZone OS, which is isolated from the rest of the system and manages key generation and management. Apps running in Android can call TrustZone OS for key generation and other secure functions, such as sign and encrypt.
Cryptographic functions which are required within this OS are implemented by smartphone vendors. This leads to vendors creating proprietary and undocumented designs. Researchers reverse engineered the implementations used by Samsung. In the case of Samsung, the TrustZone OS stores keys by using an IV and salt to create “blobs” using a form of AES.
However, in the Samsung Galaxy S9, the IV was controlled by Android, not by TrustZone. Furthermore, the salt is derived from values that the requesting application has complete control over. This leads to the reuse of both keys and IV.
Given a key blob encrypting some unknown key, it is possible for an attacker to use known IV and salt to generate a new key blob of a new known key. The attacker can then XOR the key blobs and the known key to get the unknown key. So without breaking into the TrustZone OS itself and only compromising Android, an attacker can get all the user’s secret keys.
For the TrustZone OS key generation in the Samsung Galaxy S10 finally included a randomized salt which prevents the attack mentioned above. Instead, it was possible to request TrustZone to run an older version of key generation, which downgrades security to once again allows the prior attack. This downgrade attack was also possible on the S20 and S21. Using these attacks, the researchers showed that it was trivial to break WebAuth as well as biometric confirmation.
These vulnerabilities have since been patched by Samsung, but it shows many issues. At a cryptographic level, the client was allowed to set the IV and the encryption version there was latent code in the application, and there were old encryptions after upgrades of the system. There was also a gap in composability as this was a closed source vendor-specific implementation.
As another consequence of the code not being open-source, it likely took researchers far longer to complete their research. Furthermore, it was not possible to find these vulnerabilities before they reached production. These kinds of exploits can be avoided in the future by embracing open-standard designs.
The full paper can be found at: https://eprint.iacr.org/2022/208.pdf


