Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[security] Without verifying whether malloc is successful, copy the enclave buf outside directly #70

Open
jmp0x7c00 opened this issue Mar 28, 2022 · 3 comments

Comments

@jmp0x7c00
Copy link

in file win/Enclave/Current_bloomberg.cpp:

static int construct_query(char* symbol, char** buf) {
    int len;
    char query[1000];
    query[0] = 0;

    strncat(query, "/quote/", sizeof query);
    strncat(query, symbol, sizeof query);
    strncat(query, ":US", sizeof query);

    len = strlen(query);
    *buf = (char*)malloc(len+1);
    // doesn't check malloc result. buf may be NULL
    memcpy(*buf, query, len);
    (*buf)[len] = 0;
    return len;
}

and here:

static int parse_response(char* resp, char** buf) {
    int len;
    char ret[100];
    char * end;
    char * temp = resp;

    while (strncmp(temp, "itemprop=\"price\"", 16) != 0) {
        temp += 1;
    }
    temp += 17;
    while (*temp != '"') {
        temp += 1;
    }
    temp += 1;
    end = temp;
    while (*end != '"') {
        end += 1;
    }
    *end = 0;


    /*double price;
    
    price = atof(resp);*/
    
    ret[0] = 0;
    strncat(ret, temp, sizeof ret);

    len = strlen(ret);
    *buf = (char*)malloc(len+1);
//doesn't check malloc result. buf may be NULL
    memcpy(*buf, ret, len);
    (*buf)[len] = 0;
    return len;
}
@jmp0x7c00
Copy link
Author

same bugs in file win/Enclave/Steam2.cpp:
line 49:

 *buf = (char*)malloc(len+1);
    memcpy(*buf, query, len);
    (*buf)[len] = 0;
    return len;

and line 115

*resp = (char*)malloc(len+1);
    memcpy(*resp, query, len);

and line 69:

  *buf = (char*)malloc(len+1);
    memcpy(*buf, query, len);
    (*buf)[len] = 0;

@jmp0x7c00
Copy link
Author

file win/Enclave/Current_Yahoo.cpp:
line 20:

*buf = (char*)malloc(len+1);
    memcpy(*buf, query, len);

and file win/Enclave/Current_Google.cpp line 48
and file win/Enclave/Transaction.cpp line 202
and file /win/Enclave/Flight.cpp line 64
and file win/Enclave/ECDAS.c line 101

@bl4ck5un
Copy link
Owner

Thanks. Do you want to submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants