Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler. Number of rules (primarily dangerous function names) in C/C++ ruleset: 223 Examining data/shellinabox-2.21/libhttp/hashmap.c Examining data/shellinabox-2.21/libhttp/hashmap.h Examining data/shellinabox-2.21/libhttp/http.h Examining data/shellinabox-2.21/libhttp/httpconnection.c Examining data/shellinabox-2.21/libhttp/httpconnection.h Examining data/shellinabox-2.21/libhttp/server.c Examining data/shellinabox-2.21/libhttp/server.h Examining data/shellinabox-2.21/libhttp/ssl.c Examining data/shellinabox-2.21/libhttp/ssl.h Examining data/shellinabox-2.21/libhttp/trie.c Examining data/shellinabox-2.21/libhttp/trie.h Examining data/shellinabox-2.21/libhttp/url.c Examining data/shellinabox-2.21/libhttp/url.h Examining data/shellinabox-2.21/logging/logging.c Examining data/shellinabox-2.21/logging/logging.h Examining data/shellinabox-2.21/shellinabox/externalfile.c Examining data/shellinabox-2.21/shellinabox/externalfile.h Examining data/shellinabox-2.21/shellinabox/launcher.c Examining data/shellinabox-2.21/shellinabox/launcher.h Examining data/shellinabox-2.21/shellinabox/privileges.c Examining data/shellinabox-2.21/shellinabox/privileges.h Examining data/shellinabox-2.21/shellinabox/service.c Examining data/shellinabox-2.21/shellinabox/service.h Examining data/shellinabox-2.21/shellinabox/session.c Examining data/shellinabox-2.21/shellinabox/session.h Examining data/shellinabox-2.21/shellinabox/shellinaboxd.c Examining data/shellinabox-2.21/shellinabox/usercss.c Examining data/shellinabox-2.21/shellinabox/usercss.h FINAL RESULTS: data/shellinabox-2.21/libhttp/httpconnection.c:274:9: [5] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is high; the length parameter appears to be a constant, instead of computing the number of characters left. strncat(lengthBuf, "-", sizeof(lengthBuf)-1); data/shellinabox-2.21/libhttp/server.c:315:9: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. if (chown(unixDomainPath, unixDomainUser, unixDomainGroup)) { data/shellinabox-2.21/libhttp/server.c:319:9: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. if (chmod(unixDomainPath, unixDomainChmod)) { data/shellinabox-2.21/libhttp/ssl.c:853:14: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. if ((i = readlink(proc, buf + 1, len-3)) < 0) { data/shellinabox-2.21/libhttp/http.h:120:25: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__((format(printf, 4, 5))); data/shellinabox-2.21/libhttp/http.h:122:58: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. ...) __attribute__((format(printf, 3, 4))); data/shellinabox-2.21/libhttp/httpconnection.h:140:25: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__((format(printf, 4, 5))); data/shellinabox-2.21/libhttp/httpconnection.h:143:25: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__((format(printf, 3, 4))); data/shellinabox-2.21/libhttp/ssl.c:404:9: [4] (shell) execlp: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. if (execlp("openssl", "openssl", "req", "-x509", "-nodes", "-days", "7300", data/shellinabox-2.21/logging/logging.c:72:5: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, fmt, ap); data/shellinabox-2.21/logging/logging.c:178:19: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. int p = vsnprintf(buf + offset, len, fmt, aq); data/shellinabox-2.21/logging/logging.c:183:11: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. check(vsnprintf(buf + offset, p + 1, fmt, aq) == p); data/shellinabox-2.21/logging/logging.c:195:19: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. p = vsnprintf(buf + offset, len, fmt, ap); data/shellinabox-2.21/logging/logging.h:72:58: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. void debug(const char *fmt, ...) __attribute__((format(printf, 1, 2))); data/shellinabox-2.21/logging/logging.h:73:58: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. void info(const char *fmt, ...) __attribute__((format(printf, 1, 2))); data/shellinabox-2.21/logging/logging.h:74:58: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. void warn(const char *fmt, ...) __attribute__((format(printf, 1, 2))); data/shellinabox-2.21/logging/logging.h:75:58: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. void error(const char *fmt, ...) __attribute__((format(printf, 1, 2))); data/shellinabox-2.21/logging/logging.h:76:58: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. void message(const char *fmt, ...) __attribute__((format(printf, 1, 2))); data/shellinabox-2.21/logging/logging.h:77:58: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. void fatal(const char *fmt, ...) __attribute__((format(printf, 1, 2), data/shellinabox-2.21/logging/logging.h:91:25: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__((format(printf, 2, 3))); data/shellinabox-2.21/shellinabox/launcher.c:50:9: [4] (shell) execle: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. #define execle x_execle data/shellinabox-2.21/shellinabox/launcher.c:135:8: [4] (shell) execle: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. #undef execle data/shellinabox-2.21/shellinabox/launcher.c:136:5: [4] (shell) execle: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. int execle(const char *, const char *, ...); data/shellinabox-2.21/shellinabox/launcher.c:623:3: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. snprintf(remoteHost, 256, data/shellinabox-2.21/shellinabox/launcher.c:790:3: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(buf, p); data/shellinabox-2.21/shellinabox/launcher.c:831:5: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy (ptyPath, path); data/shellinabox-2.21/shellinabox/launcher.c:859:11: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(ptyPath, fname); data/shellinabox-2.21/shellinabox/launcher.c:1474:7: [4] (shell) execvp: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. if (execvp(cmd, argv) < 0) { data/shellinabox-2.21/shellinabox/launcher.c:1682:5: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. snprintf(remoteHost, 256, data/shellinabox-2.21/shellinabox/launcher.c:1685:5: [4] (shell) execle: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execle("/bin/login", "login", "-p", "-h", remoteHost, data/shellinabox-2.21/shellinabox/launcher.c:1687:5: [4] (shell) execle: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execle("/usr/bin/login", "login", "-p", "-h", remoteHost, data/shellinabox-2.21/shellinabox/shellinaboxd.c:203:12: [4] (format) vprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. int rc = vprintf(format, ap); data/shellinabox-2.21/libhttp/server.c:351:5: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand((int)(tv.tv_usec ^ tv.tv_sec)); data/shellinabox-2.21/shellinabox/launcher.c:1534:35: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char *value = getenv(legalEnv[i]); data/shellinabox-2.21/shellinabox/shellinaboxd.c:942:30: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. int c = getopt_long(argc, argv, optstring, options, &idx); data/shellinabox-2.21/libhttp/hashmap.c:179:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&hashmap->entries[idx][i], &hashmap->entries[idx][j-1], data/shellinabox-2.21/libhttp/hashmap.c:228:13: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&hashmap->entries[i][j], &hashmap->entries[i][count-1], data/shellinabox-2.21/libhttp/httpconnection.c:96:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(http->partial + http->partialLength, buf, len); data/shellinabox-2.21/libhttp/httpconnection.c:266:7: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char timeBuf[80]; data/shellinabox-2.21/libhttp/httpconnection.c:267:7: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lengthBuf[40]; data/shellinabox-2.21/libhttp/httpconnection.c:307:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char host[256]; data/shellinabox-2.21/libhttp/httpconnection.c:568:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(*header + *headerLength, tmp, tmpLength); data/shellinabox-2.21/libhttp/httpconnection.c:569:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(*header + *headerLength + tmpLength, "\r\n", 2); data/shellinabox-2.21/libhttp/httpconnection.c:643:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(header, msg, headerLength); data/shellinabox-2.21/libhttp/httpconnection.c:697:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(http->msg + http->msgLength, header, headerLength); data/shellinabox-2.21/libhttp/httpconnection.c:718:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(http->msg + http->msgLength, msg + bodyOffset, len - bodyOffset); data/shellinabox-2.21/libhttp/httpconnection.c:929:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(http->matchedPath, http->path, diff - http->path); data/shellinabox-2.21/libhttp/httpconnection.c:937:11: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(http->pathInfo, diff, endOfInfo - diff); data/shellinabox-2.21/libhttp/httpconnection.c:1417:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[4096]; data/shellinabox-2.21/libhttp/httpconnection.c:1448:7: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char method[12] = { 0 }; data/shellinabox-2.21/libhttp/httpconnection.c:1577:13: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(http->partial, buf + offset, pushBack); data/shellinabox-2.21/libhttp/server.c:167:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(payload->bytes + payload->len, buf, len); data/shellinabox-2.21/libhttp/server.c:174:27: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). ((contentLength && atoi(contentLength) <= payload->len) || !buf))) { data/shellinabox-2.21/libhttp/ssl.c:228:23: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int null = NOINTR(open("/dev/null", O_WRONLY)); data/shellinabox-2.21/libhttp/ssl.c:392:28: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int fd = NOINTR(open("/dev/null", O_RDONLY)); data/shellinabox-2.21/libhttp/ssl.c:396:28: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd = NOINTR(open("/dev/null", O_WRONLY)); data/shellinabox-2.21/libhttp/ssl.c:443:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(newBuf, buf, len); data/shellinabox-2.21/libhttp/ssl.c:606:12: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int fd = open(filename, O_RDONLY); data/shellinabox-2.21/libhttp/ssl.c:802:7: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char hostname[256], buf[4096]; data/shellinabox-2.21/libhttp/trie.c:98:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(trie->key, key, len); data/shellinabox-2.21/libhttp/trie.c:124:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(child->key, trie->key + i + 1, trie->idx - i - 1); data/shellinabox-2.21/libhttp/url.c:110:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(s, buf, len); data/shellinabox-2.21/shellinabox/externalfile.c:111:37: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int fd = NOINTR(open(fn, O_RDONLY|O_LARGEFILE)); data/shellinabox-2.21/shellinabox/launcher.c:208:26: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int nullFd = open("/dev/null", O_RDWR); data/shellinabox-2.21/shellinabox/launcher.c:228:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[128]; data/shellinabox-2.21/shellinabox/launcher.c:539:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&request->url, u, request->urlLength); data/shellinabox-2.21/shellinabox/launcher.c:547:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char cmsg_buf[CMSG_SPACE(sizeof(int))]; data/shellinabox-2.21/shellinabox/launcher.c:566:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&session->pty, CMSG_DATA(cmsg), sizeof(int)); data/shellinabox-2.21/shellinabox/launcher.c:599:9: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. const char pid[32]; data/shellinabox-2.21/shellinabox/launcher.c:622:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char remoteHost[256]; data/shellinabox-2.21/shellinabox/launcher.c:721:17: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int nullFd = open("/dev/null", O_RDWR); data/shellinabox-2.21/shellinabox/launcher.c:747:17: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). int fd = atoi(res->d_name); data/shellinabox-2.21/shellinabox/launcher.c:835:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char ptyPath[PATH_MAX]; data/shellinabox-2.21/shellinabox/launcher.c:840:38: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). (slave = NOINTR(open(ptyPath, O_RDWR|O_NOCTTY))) < 0) { data/shellinabox-2.21/shellinabox/launcher.c:846:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char fname[40] = "/dev/ptyXX"; data/shellinabox-2.21/shellinabox/launcher.c:851:38: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if ((*pty = NOINTR(open(fname, O_RDWR, 0))) < 0) { data/shellinabox-2.21/shellinabox/launcher.c:862:38: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if ((slave = NOINTR(open(ptyPath, O_RDWR|O_NOCTTY))) >= 0) { data/shellinabox-2.21/shellinabox/launcher.c:916:25: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). NOINTR(close(NOINTR(open(ptyPath, O_RDWR)))); data/shellinabox-2.21/shellinabox/launcher.c:1287:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(key, *e, ptr - *e); data/shellinabox-2.21/shellinabox/launcher.c:1383:11: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(ptr, repl, replLen); data/shellinabox-2.21/shellinabox/launcher.c:1681:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char remoteHost[256]; data/shellinabox-2.21/shellinabox/launcher.c:1732:9: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char key[32]; data/shellinabox-2.21/shellinabox/launcher.c:1770:9: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char key[32]; data/shellinabox-2.21/shellinabox/launcher.c:1837:7: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char cmsg_buf[CMSG_SPACE(sizeof(int))]; // = { 0 }; // Valid initializer makes OSX mad. data/shellinabox-2.21/shellinabox/launcher.c:1852:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(CMSG_DATA(cmsg), &pty, sizeof(int)); data/shellinabox-2.21/shellinabox/launcher.h:58:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char peerName[128]; data/shellinabox-2.21/shellinabox/launcher.h:59:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char realIP[128]; data/shellinabox-2.21/shellinabox/launcher.h:61:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char url[0]; data/shellinabox-2.21/shellinabox/service.c:86:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy((char *)service->path + 1, arg, ptr - arg); data/shellinabox-2.21/shellinabox/service.c:144:11: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(host, ptr, size - 1); data/shellinabox-2.21/shellinabox/session.c:175:22: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). check((fd = NOINTR(open("/dev/urandom", O_RDONLY))) >= 0); data/shellinabox-2.21/shellinabox/session.c:176:12: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char buf[16]; data/shellinabox-2.21/shellinabox/shellinaboxd.c:217:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(session->buffered + session->len, buf, len); data/shellinabox-2.21/shellinabox/shellinaboxd.c:221:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(session->buffered, buf, len); data/shellinabox-2.21/shellinabox/shellinaboxd.c:231:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(session->buffered + session->len, buf, len); data/shellinabox-2.21/shellinabox/shellinaboxd.c:248:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(session->buffered, buf + maxLength, session->len); data/shellinabox-2.21/shellinabox/shellinaboxd.c:310:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[MAX_RESPONSE]; data/shellinabox-2.21/shellinabox/shellinaboxd.c:413:29: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). session->width = atoi(width); data/shellinabox-2.21/shellinabox/shellinaboxd.c:414:29: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). session->height = atoi(height); data/shellinabox-2.21/shellinabox/shellinaboxd.c:545:11: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(tag, ptr + 4, bracket - ptr - 4); data/shellinabox-2.21/shellinabox/shellinaboxd.c:580:13: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(body, start, end - start); data/shellinabox-2.21/shellinabox/shellinaboxd.c:639:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(response + len, body, bodyEnd - body); data/shellinabox-2.21/shellinabox/shellinaboxd.c:739:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(memcpy(memcpy( data/shellinabox-2.21/shellinabox/shellinaboxd.c:739:14: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(memcpy(memcpy( data/shellinabox-2.21/shellinabox/shellinaboxd.c:739:21: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(memcpy(memcpy( data/shellinabox-2.21/shellinabox/shellinaboxd.c:759:29: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). for (int idx = atoi(pathInfo + 8); data/shellinabox-2.21/shellinabox/shellinaboxd.c:1015:30: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). FILE *css = fopen(optarg, "r"); data/shellinabox-2.21/shellinabox/shellinaboxd.c:1069:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(path, optarg, ptr - optarg); data/shellinabox-2.21/shellinabox/shellinaboxd.c:1308:37: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int fd = NOINTR(open(pidfile, data/shellinabox-2.21/shellinabox/shellinaboxd.c:1312:7: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[40]; data/shellinabox-2.21/shellinabox/shellinaboxd.c:1473:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[40]; data/shellinabox-2.21/shellinabox/shellinaboxd.c:1474:21: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int fd = open(pidfile, O_RDONLY); data/shellinabox-2.21/shellinabox/shellinaboxd.c:1481:13: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). if (atoi(buf) == getpid()) { data/shellinabox-2.21/shellinabox/usercss.c:80:29: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int fd = open(filename, O_RDONLY); data/shellinabox-2.21/shellinabox/usercss.c:102:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(def, *style + 3, e - *style - 3); data/shellinabox-2.21/shellinabox/usercss.c:128:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy((char *)dst, "<", 4); data/shellinabox-2.21/shellinabox/usercss.c:131:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy((char *)dst, "&", 5); data/shellinabox-2.21/shellinabox/usercss.c:134:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy((char *)dst, "'", 6); data/shellinabox-2.21/shellinabox/usercss.c:137:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy((char *)dst, """, 6); data/shellinabox-2.21/shellinabox/usercss.c:147:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(filename, colon + 1, filenameLen); data/shellinabox-2.21/libhttp/httpconnection.c:67:9: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. #define strncat(a,b,c) ({ char *_a = (a); strlcat(_a, (b), (c)+1); _a; }) data/shellinabox-2.21/libhttp/httpconnection.c:151:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). rc = NOINTR(read(http->fd, buf, len)); data/shellinabox-2.21/libhttp/httpconnection.c:228:13: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int len = strlen(needle); data/shellinabox-2.21/libhttp/httpconnection.c:456:25: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int encodingLength = strlen(encoding); data/shellinabox-2.21/libhttp/httpconnection.c:528:24: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int idLength = strlen(id); data/shellinabox-2.21/libhttp/httpconnection.c:561:22: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int tmpLength = strlen(tmp); data/shellinabox-2.21/libhttp/httpconnection.c:812:34: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). httpTransfer(http, response, strlen(response)); data/shellinabox-2.21/libhttp/httpconnection.c:905:42: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). httpTransfer(http, response, strlen(response)); data/shellinabox-2.21/libhttp/httpconnection.c:1042:30: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int oldLength = strlen(*oldValue); data/shellinabox-2.21/libhttp/httpconnection.c:1791:39: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). (long)strlen(body)); data/shellinabox-2.21/libhttp/httpconnection.c:1799:32: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). httpTransfer(http, response, strlen(response)); data/shellinabox-2.21/libhttp/httpconnection.c:1815:24: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). len = strlen(buf); data/shellinabox-2.21/libhttp/httpconnection.c:1951:38: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int s_size = 8 + strlen(host) + 25 + strlen(http->path); data/shellinabox-2.21/libhttp/httpconnection.c:1951:58: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int s_size = 8 + strlen(host) + 25 + strlen(http->path); data/shellinabox-2.21/libhttp/httpconnection.c:1954:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(http->url, http->sslHndl ? "https://" : "http://", s_size); data/shellinabox-2.21/libhttp/httpconnection.c:1955:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(http->url, host, s_size); data/shellinabox-2.21/libhttp/httpconnection.c:1959:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(http->url, http->path, s_size); data/shellinabox-2.21/libhttp/server.c:309:39: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). + strlen(unixDomainPath); data/shellinabox-2.21/libhttp/ssl.c:400:5: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(077); data/shellinabox-2.21/libhttp/ssl.c:430:32: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t bytesRead = NOINTR(read(fd, buf + len, readLen)); data/shellinabox-2.21/libhttp/ssl.c:469:24: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). ptr += strlen(marker); data/shellinabox-2.21/libhttp/ssl.c:475:30: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). *eor = end + strlen(marker); data/shellinabox-2.21/libhttp/ssl.c:533:40: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). long dataSize = (long)strlen((const char *)data); data/shellinabox-2.21/libhttp/ssl.c:700:36: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). check(serverName = malloc(strlen(name)+2)); data/shellinabox-2.21/libhttp/ssl.c:795:27: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). memmove(ptr, ptr + 2, strlen(ptr)-1); data/shellinabox-2.21/libhttp/trie.c:113:38: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). addLeafToTrie(trie, '\000', key, strlen(key), value); data/shellinabox-2.21/libhttp/trie.c:116:37: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int len = strlen(key); data/shellinabox-2.21/libhttp/url.c:184:21: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int sLen = strlen(s); data/shellinabox-2.21/libhttp/url.c:207:14: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int sLen = strlen(s); data/shellinabox-2.21/libhttp/url.c:216:14: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int sLen = strlen(s); data/shellinabox-2.21/libhttp/url.c:276:57: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). urlParseHeaderLine(&contentType, ctHeader, ctHeader ? strlen(ctHeader) : 0); data/shellinabox-2.21/libhttp/url.c:290:30: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int i = strlen(boundary); data/shellinabox-2.21/libhttp/url.c:365:49: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). urlParseQueryString(&url->args, url->query, strlen(url->query)); data/shellinabox-2.21/libhttp/url.c:430:38: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int s_size = 8 + strlen(host) + 25 + strlen(url->path); data/shellinabox-2.21/libhttp/url.c:430:58: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int s_size = 8 + strlen(host) + 25 + strlen(url->path); data/shellinabox-2.21/libhttp/url.c:433:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(url->url, url->protocol, s_size); data/shellinabox-2.21/libhttp/url.c:434:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is low because the source is a constant string. strncat(url->url, "://", s_size); data/shellinabox-2.21/libhttp/url.c:435:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(url->url, host, s_size); data/shellinabox-2.21/libhttp/url.c:439:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(url->url, url->path, s_size); data/shellinabox-2.21/logging/logging.c:173:25: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int offset = buf ? strlen(buf) : 0; data/shellinabox-2.21/shellinabox/externalfile.c:63:9: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. #define strncat(a,b,c) ({ char *_a = (a); strlcat(_a, (b), (c)+1); _a; }) data/shellinabox-2.21/shellinabox/externalfile.c:81:30: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int s_size = strlen((char *)arg) + data/shellinabox-2.21/shellinabox/externalfile.c:82:43: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). (*pathInfo ? strlen(pathInfo) + 1 : 0); data/shellinabox-2.21/shellinabox/externalfile.c:85:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(fn, (char *)arg, s_size); data/shellinabox-2.21/shellinabox/externalfile.c:88:7: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is low because the source is a constant character. strncat(fn, "/", s_size); data/shellinabox-2.21/shellinabox/externalfile.c:93:7: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(fn, ptr, s_size); data/shellinabox-2.21/shellinabox/externalfile.c:172:30: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int respLen = strlen(response); data/shellinabox-2.21/shellinabox/externalfile.c:182:37: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). bytes = NOINTR(read(fd, response + respLen, dataLen)); data/shellinabox-2.21/shellinabox/externalfile.c:230:37: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t bytes = NOINTR(read(state->fd, buf, dataLen)); data/shellinabox-2.21/shellinabox/externalfile.c:259:20: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int s_size = strlen(services[i]->path) + strlen(key) + 1; data/shellinabox-2.21/shellinabox/externalfile.c:259:48: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int s_size = strlen(services[i]->path) + strlen(key) + 1; data/shellinabox-2.21/shellinabox/externalfile.c:262:7: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(path, services[i]->path, s_size); data/shellinabox-2.21/shellinabox/externalfile.c:265:9: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is low because the source is a constant character. strncat(path, "/", s_size); data/shellinabox-2.21/shellinabox/externalfile.c:267:7: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(path, key, s_size); data/shellinabox-2.21/shellinabox/launcher.c:115:9: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. #define strncat(a,b,c) ({ char *_a = (a); strlcat(_a, (b), (c)+1); _a; }) data/shellinabox-2.21/shellinabox/launcher.c:229:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (NOINTR(read(fds[0], buf, sizeof(buf))) > 0) { data/shellinabox-2.21/shellinabox/launcher.c:247:9: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(&ut->ut_user[0], user, sizeof(ut->ut_user) - 1); data/shellinabox-2.21/shellinabox/launcher.c:291:26: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). nc = read(0, line, lineLength - 1); data/shellinabox-2.21/shellinabox/launcher.c:518:37: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). check(u = realloc(u, strlen(u) + 4)); data/shellinabox-2.21/shellinabox/launcher.c:519:35: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). memmove(u + i + 3, u + i + 1, strlen(u + i)); data/shellinabox-2.21/shellinabox/launcher.c:526:57: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). ssize_t len = sizeof(struct LaunchRequest) + strlen(u) + 1; data/shellinabox-2.21/shellinabox/launcher.c:533:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(request->peerName, peerName, sizeof(request->peerName) - 1); data/shellinabox-2.21/shellinabox/launcher.c:536:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(request->realIP, realIP, sizeof(request->realIP) - 1); data/shellinabox-2.21/shellinabox/launcher.c:538:26: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). request->urlLength = strlen(u); data/shellinabox-2.21/shellinabox/launcher.c:619:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(&utmp->utmpx.ut_line[0], ptyPath + 5, sizeof(utmp->utmpx.ut_line) - 1); data/shellinabox-2.21/shellinabox/launcher.c:620:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(&utmp->utmpx.ut_id[0], ptyPath + 8, sizeof(utmp->utmpx.ut_id) - 1); data/shellinabox-2.21/shellinabox/launcher.c:621:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is low because the source is a constant string. strncat(&utmp->utmpx.ut_user[0], "SHELLINABOX", sizeof(utmp->utmpx.ut_user) - 1); data/shellinabox-2.21/shellinabox/launcher.c:626:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(&utmp->utmpx.ut_host[0], remoteHost, sizeof(utmp->utmpx.ut_host) - 1); data/shellinabox-2.21/shellinabox/launcher.c:786:16: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (buflen < strlen(p) + 1) { data/shellinabox-2.21/shellinabox/launcher.c:829:14: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). length = strlen (path); data/shellinabox-2.21/shellinabox/launcher.c:951:46: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen(pw->pw_name) + data/shellinabox-2.21/shellinabox/launcher.c:952:46: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen(pw->pw_passwd) + data/shellinabox-2.21/shellinabox/launcher.c:953:46: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen(pw->pw_gecos) + data/shellinabox-2.21/shellinabox/launcher.c:954:46: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen(pw->pw_dir) + data/shellinabox-2.21/shellinabox/launcher.c:955:46: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen(pw->pw_shell) + 5, 1)); data/shellinabox-2.21/shellinabox/launcher.c:958:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(passwd->pw_shell = strrchr( data/shellinabox-2.21/shellinabox/launcher.c:959:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(passwd->pw_dir = strrchr( data/shellinabox-2.21/shellinabox/launcher.c:960:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(passwd->pw_gecos = strrchr( data/shellinabox-2.21/shellinabox/launcher.c:961:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(passwd->pw_passwd = strrchr( data/shellinabox-2.21/shellinabox/launcher.c:962:3: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(passwd->pw_name = (char *)(passwd + 1), data/shellinabox-2.21/shellinabox/launcher.c:963:25: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). pw->pw_name, strlen(pw->pw_name)), '\000') + 1, data/shellinabox-2.21/shellinabox/launcher.c:964:25: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). pw->pw_passwd, strlen(pw->pw_passwd)), '\000') + 1, data/shellinabox-2.21/shellinabox/launcher.c:965:25: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). pw->pw_gecos, strlen(pw->pw_gecos)), '\000') + 1, data/shellinabox-2.21/shellinabox/launcher.c:966:25: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). pw->pw_dir, strlen(pw->pw_dir)), '\000') + 1, data/shellinabox-2.21/shellinabox/launcher.c:967:25: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). pw->pw_shell, strlen(pw->pw_shell)); data/shellinabox-2.21/shellinabox/launcher.c:1054:42: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen(cmdline) + strlen(fqdn) - data/shellinabox-2.21/shellinabox/launcher.c:1054:60: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen(cmdline) + strlen(fqdn) - data/shellinabox-2.21/shellinabox/launcher.c:1055:42: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen("localhost") + 1)); data/shellinabox-2.21/shellinabox/launcher.c:1058:7: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(ptr, fqdn, strlen(fqdn)); data/shellinabox-2.21/shellinabox/launcher.c:1058:26: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strncat(ptr, fqdn, strlen(fqdn)); data/shellinabox-2.21/shellinabox/launcher.c:1245:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(&utmp->utmpx.ut_user[0], service->user, data/shellinabox-2.21/shellinabox/launcher.c:1333:31: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). memmove(ptr, ptr + 1, strlen(ptr)); data/shellinabox-2.21/shellinabox/launcher.c:1342:31: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). memmove(ptr, ptr + 1, strlen(ptr)); data/shellinabox-2.21/shellinabox/launcher.c:1361:40: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int replLen = repl ? strlen(repl) : 0; data/shellinabox-2.21/shellinabox/launcher.c:1370:59: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). (end - cmdline) + strlen(end) + data/shellinabox-2.21/shellinabox/launcher.c:1381:37: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). memmove(ptr + replLen, end, strlen(end) + 1); data/shellinabox-2.21/shellinabox/launcher.c:1392:31: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). memmove(ptr, ptr + 1, strlen(ptr)); data/shellinabox-2.21/shellinabox/launcher.c:1417:33: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int len = strlen(key); data/shellinabox-2.21/shellinabox/launcher.c:1420:39: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int s_size = len + strlen(value) + 1; data/shellinabox-2.21/shellinabox/launcher.c:1423:15: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(*e, value, s_size); data/shellinabox-2.21/shellinabox/launcher.c:1465:33: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). memmove(argv[0], slash + 1, strlen(slash)); data/shellinabox-2.21/shellinabox/launcher.c:1468:33: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int len = strlen(argv[0]); data/shellinabox-2.21/shellinabox/launcher.c:1587:7: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is low because the source is a constant string. strncat(&utmpx.ut_user[0], "LOGIN", sizeof(utmpx.ut_user) - 1); data/shellinabox-2.21/shellinabox/launcher.c:1660:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. Risk is low because the source is a constant character. strncat((char *)service->cwd, "/", 1); data/shellinabox-2.21/shellinabox/launcher.c:1716:33: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int len = read(fd, &request, sizeof(request)); data/shellinabox-2.21/shellinabox/launcher.c:1760:33: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). len = read(fd, url, request.urlLength + 1); data/shellinabox-2.21/shellinabox/session.c:177:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). check(NOINTR(read(fd, buf, sizeof(buf))) == sizeof(buf)); data/shellinabox-2.21/shellinabox/shellinaboxd.c:270:52: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). (long)strlen(json), data/shellinabox-2.21/shellinabox/shellinaboxd.c:275:34: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). httpTransfer(http, response, strlen(response)); data/shellinabox-2.21/shellinabox/shellinaboxd.c:313:42: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). bytes = NOINTR(read(session->pty, buf, len)); data/shellinabox-2.21/shellinabox/shellinaboxd.c:458:36: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). check(keyCodes = malloc(strlen(keys)/2)); data/shellinabox-2.21/shellinabox/shellinaboxd.c:589:61: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). } else if (ifPtr && !elsePtr && eol - ptr >= (ssize_t)strlen(tag) + 7 && data/shellinabox-2.21/shellinabox/shellinaboxd.c:591:40: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). !memcmp(ptr + 6, tag, strlen(tag)) && data/shellinabox-2.21/shellinabox/shellinaboxd.c:592:26: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). ptr[6 + strlen(tag)] == ']') { data/shellinabox-2.21/shellinabox/shellinaboxd.c:595:49: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). } else if (ifPtr && eol - ptr >= (ssize_t)strlen(tag) + 8 && data/shellinabox-2.21/shellinabox/shellinaboxd.c:597:40: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). !memcmp(ptr + 7, tag, strlen(tag)) && data/shellinabox-2.21/shellinabox/shellinaboxd.c:598:26: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). ptr[7 + strlen(tag)] == ']') { data/shellinabox-2.21/shellinabox/shellinaboxd.c:636:22: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int len = strlen(response); data/shellinabox-2.21/shellinabox/shellinaboxd.c:668:20: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). pathInfoLength = strlen (pathInfo); data/shellinabox-2.21/shellinabox/shellinaboxd.c:726:29: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int stateVarsLength = strlen(stateVars); data/shellinabox-2.21/shellinabox/shellinaboxd.c:736:29: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int headerLength = strlen(response); data/shellinabox-2.21/shellinabox/shellinaboxd.c:1019:53: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). check(cssStyleSheet= realloc(cssStyleSheet, strlen(cssStyleSheet) + data/shellinabox-2.21/shellinabox/shellinaboxd.c:1216:11: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (strlen(ptr) == 1) { data/shellinabox-2.21/shellinabox/shellinaboxd.c:1399:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). check(!NOINTR(read(fds[0], &wait, 1))); data/shellinabox-2.21/shellinabox/shellinaboxd.c:1477:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). NOINTR(sz = read(fd, buf, sizeof(buf)-1)); ANALYSIS SUMMARY: Hits = 245 Lines analyzed = 11239 in approximately 0.31 seconds (36779 lines/second) Physical Source Lines of Code (SLOC) = 8729 Hits@level = [0] 25 [1] 125 [2] 85 [3] 3 [4] 28 [5] 4 Hits@level+ = [0+] 270 [1+] 245 [2+] 120 [3+] 35 [4+] 32 [5+] 4 Hits/KSLOC@level+ = [0+] 30.9314 [1+] 28.0674 [2+] 13.7473 [3+] 4.00962 [4+] 3.66594 [5+] 0.458243 Minimum risk level = 1 Not every hit is necessarily a security vulnerability. There may be other security vulnerabilities; review your code! See 'Secure Programming HOWTO' (https://dwheeler.com/secure-programs) for more information.