The recent discovery of a vulnerability in the CVE-2021-26391 classified as "insufficient verification of multiple header signatures while loading a Trusted Application (TA)" has raised concerns among developers and security experts. An attacker with privileges may exploit this vulnerability to gain code execution in the Trusted Application or the OS/kernel.

In this long-read post, we will discuss the details of the vulnerability, analyze a code snippet, and provide essential resources to fully comprehend the issue.

Background

Trusted Applications play a crucial role in providing isolated and secure execution environments for sensitive code and data, segregating them from the normal operating system. In most implementations, Trusted Applications run in a Trusted Execution Environment (TEE) – a separate and isolated environment that operates alongside the main OS. The TEE ensures that sensitive code and data used by Trusted Applications are protected from malicious applications and users with privileges on the device.

Vulnerability: CVE-2021-26391

Insufficient verification of multiple header signatures while loading a Trusted Application can allow an attacker to forge their header signatures or create a valid TA header containing malicious code. This vulnerability exposes the TA and potentially the OS/kernel as an attacker can gain code execution privileges.

Exploit Details

The vulnerability resides in a piece of code responsible for loading and verifying the Trusted Application header. Here is a snippet of the vulnerable code:

function load_trusted_application(...) {
    ...

    // Load the signature from the payload
    signature = payload.get_signature()

    // Verify the signature
    if (!verify_signature(signature)) {
        printf("Invalid signature. Aborting...\n")
        return -1;
    }

    ...
}

In this snippet, the load_trusted_application function attempts to verify the signature of the payload before loading it as a Trusted Application. However, the problem lies in the fact that the function only checks a single signature, giving an attacker the chance to provide multiple header signatures, which might pass the verification process without being detected.

To exploit this vulnerability, an attacker would create a payload with multiple malicious headers with the intent of bypassing the signature verification process by providing a valid, unsuspecting signature amongst the malicious headers.

Solution

A patch has been released to address this vulnerability, ensuring the satisfactory signature verification of all headers in the payload while loading a Trusted Application. The code snippet below demonstrates how to address the issue:

function load_trusted_application(...) {
    ...

    // Load the signatures from the payload
    signatures = payload.get_signatures()

    // Verify all signatures
    for (signature in signatures) {
        if (!verify_signature(signature)) {
            printf("Invalid signature detected. Aborting...\n")
            return -1;
        }
    }

    ...
}

With this patch, the function now verifies all header signatures within the payload. As a result, attackers can no longer forge or bypass signature verification with multiple header signatures.

Original References

1. CVE-2021-26391 - National Vulnerability Database
2. Trusted Applications and the Trusted Execution Environment

Conclusion

The recent discovery of the CVE-2021-26391 vulnerability has demonstrated the significance of ensuring strong security practices within Trusted Applications and their loading mechanism. By addressing this vulnerability, developers and security experts can continue to rely on the isolation and security promises of Trusted Applications and the Trusted Execution Environment. Always remember to stay vigilant and updated on your security patches to protect your systems against threats.

Timeline

Published on: 11/09/2022 21:15:00 UTC
Last modified on: 11/23/2022 14:00:00 UTC