alpine 3.6
buffer weakness #264

5

Weakness Breakdown


Definition:

Buffer overflows are one of the most well-known software vulnerabilities. Even though most developers know what buffer overflows are, attacks against the vulnerabilities are common in both legacy and newer applications. A classic buffer overflow exploit begins with the attacker sending data to a program, which it then stores in an undersized stack buffer. Besides stack buffer overflows, other kinds of buffer overflows include heap overflows, off-by-one errors and many others. Learn more about buffer overflows on OWASP attack index.

Warning code(s):

Easily used incorrectly.

File Name:

krb5/src/krb5-1.14.3/src/ccapi/common/win/win-utils.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.6 buffer weakness.

 #include "cci_debugging.h"

#pragma warning (disable : 4996)

#define UUID_SIZE   128

char*           clientPrefix        = "CCAPI_CLIENT_";
char*           serverPrefix        = "CCS_LISTEN_";
unsigned char*  pszProtocolSequence = "ncalrpc";

#define         MAX_TIMESTAMP   40
char            _ts[MAX_TIMESTAMP];

char* clientEndpoint(const char* UUID) {
    char* _clientEndpoint   = (char*)malloc(strlen(UUID) + strlen(clientPrefix) + 2);
    strcpy(_clientEndpoint, clientPrefix);
    strncat(_clientEndpoint, UUID, UUID_SIZE);
//    cci_debug_printf("%s returning %s", __FUNCTION__, _clientEndpoint);
    return _clientEndpoint;
    }

char* serverEndpoint(const char* user) {
    char* _serverEndpoint   = (char*)malloc(strlen(user) + strlen(serverPrefix) + 2);
    strcpy(_serverEndpoint, serverPrefix);
    strncat(_serverEndpoint, user, UUID_SIZE);
    return _serverEndpoint;
    }

char* timestamp() {
    SYSTEMTIME  _stime;
    GetSystemTime(&_stime);
    GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, &_stime, "HH:mm:ss", _ts, sizeof(_ts)-1);
    return _ts;
    } 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.