A newly discovered vulnerability, CVE-2022-20127, poses a significant threat to Android devices running versions Android-10, Android-11, Android-12, and Android-12L. This vulnerability exists within the ce_t4t_data_cback of ce_t4t.cc and is caused by a double free that can lead to an out-of-bounds write. Remote code execution without the need for additional execution privileges or user interaction makes this exploit particularly concerning.

In this blog post, we will delve into the details of CVE-2022-20127, examining code snippets, outlining the exploit, and linking to original references to provide comprehensive insight into this high-risk vulnerability.

Code Snippet

To understand the nature of this vulnerability, it is essential to grasp the actions inside the affected ce_t4t_data_cback function. The following is a simplified version of the relevant code snippet:

void ce_t4t_data_cback (UINT8 conn_id, tCE_EVENT event, tCE_DATA *p_ce_data) {
    
    ...
    
    if (event == CE_T4T_DATA_EVT) {
        ...
        if (p_ce_data->t4t.p_data->len) {
            if (((p_ce_data->t4t.p_data->offset >= (CE_T4T_BLOCK_SIZE * p_ce_data->t4t.p_data->blocknum)) &&
                 (p_ce_data->t4t.p_data->offset < (CE_T4T_BLOCK_SIZE * (p_ce_data->t4t.p_data->blocknum + 1)))) {
                // Possible double free and out-of-bounds write
                p_data = (UINT8 *) GKI_getbuf (data_len);
                memcpy (p_data, p_ce_data->t4t.p_data->obufstart, data_len);
                GKI_freebuf(p_data);
            }
            ...
        }
    }
    ...
}

Exploit Details

The out-of-bounds write is triggered by a double free found within the ce_t4t_data_cback function. When certain conditions are met, the function allocates memory for the p_data variable, then proceeds to copy data from the obufstart buffer into the newly allocated memory. This memory is later released using GKI_freebuf(p_data), but if the function is called again before re-allocation, an attacker can take control of the freed memory, leading to remote code execution.

Potential attackers do not require additional execution privileges to exploit this vulnerability, and user interaction is not necessary for exploitation. Consequently, Android devices could be compromised without the owner's knowledge.

For more information regarding this vulnerability, consult the following sources

- Android Public Security Bulletin - Includes a formal disclosure of CVE-2022-20127 as part of the Android Security patches and the affected components.

- Common Vulnerabilities and Exposures (CVE) Entry - Contains a brief description of the vulnerability and assigns a unique identifier (CVE-2022-20127) for future referencing.

- AOSP Repository – The ce_t4t.cc file can be found within the AOSP repository, under the platform/external/libnfc-nci directory.

Conclusion

While the discovery of CVE-2022-20127 suggests a significant security threat, it is important to stay informed and proactive in mitigating the risks. Keep your Android device updated with the latest security patches to ensure protection against this and other vulnerabilities. It is essential to maintain awareness of possible threats to protect your devices and sensitive data from potential attacks. Always verify the authenticity and security of applications before installation and refrain from downloading unknown content from untrusted sources.

Timeline

Published on: 06/15/2022 13:15:00 UTC
Last modified on: 06/23/2022 17:55:00 UTC