Skip to content

[security]write data without checking malloc result. #5

@jmp0x7c00

Description

@jmp0x7c00

Dear sir,

This code didn't check whether malloc() result is NULL and writed sensitive data to it,
as we know, the attacker can mmap the address 0, if the attacker do that, the sensitve data will be writed outside enclave.

in file PrivacyGuard/DataBroker/Enclave/enclave.cpp line ,vulnerability code is here:

sgx_status_t ECALL_enclave_DO_config(int num_DOs)
{
    int i;
    sgx_status_t ret = SGX_SUCCESS;

    sk_key_DO = (sgx_ec_key_128bit_t *) malloc(num_DOs * sizeof(sgx_ec_key_128bit_t));
    // here.
    // same issue to varaible sk_key_DO and DO_data_key_assigned 
    DO_data_key = (sgx_aes_gcm_128bit_key_t *) malloc(num_DOs * sizeof(sgx_aes_gcm_128bit_key_t));
    DO_data_key_assigned = (bool *) malloc(num_DOs * sizeof(bool));

    for(i = 0; i < num_DOs; i++)
    {
        DO_data_key_assigned[i] = false;
    }

    return ret;
}

here sensitive data is writen:

if(!DO_data_key_assigned[DO_ID-1])
    {
        /* Generate a 16-Byte data encryption key for DO's data */
        sgx_read_rand(DO_data_key[DO_ID-1], sizeof(sgx_aes_gcm_128bit_key_t));  //   the data encryption key will be leaked if malloc fails 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions