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/sucrack-1.2.3/src/dictionary.c Examining data/sucrack-1.2.3/src/dictionary.h Examining data/sucrack-1.2.3/src/pty.c Examining data/sucrack-1.2.3/src/pty.h Examining data/sucrack-1.2.3/src/rewriter.c Examining data/sucrack-1.2.3/src/rewriter.h Examining data/sucrack-1.2.3/src/rules.c Examining data/sucrack-1.2.3/src/rules.h Examining data/sucrack-1.2.3/src/stat.c Examining data/sucrack-1.2.3/src/stat.h Examining data/sucrack-1.2.3/src/su.c Examining data/sucrack-1.2.3/src/su.h Examining data/sucrack-1.2.3/src/sucrack.h Examining data/sucrack-1.2.3/src/util.c Examining data/sucrack-1.2.3/src/util.h Examining data/sucrack-1.2.3/src/worker.c Examining data/sucrack-1.2.3/src/worker.h Examining data/sucrack-1.2.3/src/sucrack.c FINAL RESULTS: data/sucrack-1.2.3/src/pty.c:51: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(mdev, PTY_DEVICE_NAME); data/sucrack-1.2.3/src/pty.c:54: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(sdev, TTY_DEVICE_NAME); data/sucrack-1.2.3/src/su.c:131:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(send_buf, "%s\n", pass); data/sucrack-1.2.3/src/su.c:190:9: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(path, X_OK) == -1) { data/sucrack-1.2.3/src/util.h:42:40: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define debug_printf(fmt, args...) fprintf(DEBUG_OUT, "DEBUG: " fmt, ##args); data/sucrack-1.2.3/src/util.h:47:34: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define err_printf(fmt, args...) fprintf(ERROR_OUT, "ERROR: " fmt, ##args); data/sucrack-1.2.3/src/util.h:49:37: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define notice_printf(fmt, args...) fprintf(NOTICE_OUT, "NOTICE: " fmt, ##args); data/sucrack-1.2.3/src/util.h:53:36: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define fatal_printf(fmt, args...) fprintf(FATAL_OUT, "FATAL: " fmt, ##args); data/sucrack-1.2.3/src/su.c:172:12: [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. path = getenv("SUCRACK_SU_PATH"); data/sucrack-1.2.3/src/su.c:178:20: [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. auth_failure = getenv("SUCRACK_AUTH_FAILURE"); data/sucrack-1.2.3/src/su.c:184:20: [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. auth_success = getenv("SUCRACK_AUTH_SUCCESS"); data/sucrack-1.2.3/src/sucrack.c:129:16: [3] (buffer) getopt: 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. while((o = getopt(argc, argv, "charw:b:s:u:l:")) != -1) { data/sucrack-1.2.3/src/dictionary.c:88:10: [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). fd = fopen(file, "r"); data/sucrack-1.2.3/src/dictionary.c:296: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 word[DICT_MAX_WORD_SIZE + 1]; data/sucrack-1.2.3/src/dictionary.c:337: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 word[DICT_MAX_WORD_SIZE + 1]; data/sucrack-1.2.3/src/pty.c:46: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 mdev[DEVICE_NAME_SIZE + 1]; data/sucrack-1.2.3/src/pty.c:47: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 sdev[DEVICE_NAME_SIZE + 1]; data/sucrack-1.2.3/src/pty.c:61:13: [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). *mfd = open(mdev, O_RDWR); data/sucrack-1.2.3/src/pty.c:65:10: [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). *sfd = open(sdev, O_RDWR); data/sucrack-1.2.3/src/pty.c:84: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 sdev[64]; data/sucrack-1.2.3/src/pty.c:87: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). *mfd = open(PT_MASTER_DEVICE_NAME, O_RDWR); data/sucrack-1.2.3/src/pty.c:96:9: [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). *sfd = open(sdev, O_RDWR); data/sucrack-1.2.3/src/su.c:55: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[BUSY_READ_BUFSZ + 1]; data/sucrack-1.2.3/src/su.c:107: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 send_buf[SU_MAX_USERNAME_LEN + 2]; data/sucrack-1.2.3/src/su.c:115:11: [2] (race) vfork: On some old systems, vfork() permits race conditions, and it's very difficult to use correctly (CWE-362). Use fork() instead. pid = vfork(); data/sucrack-1.2.3/src/sucrack.c:146:14: [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). ssec = atoi(optarg); data/sucrack-1.2.3/src/sucrack.c:158:14: [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). wnum = atoi(optarg); data/sucrack-1.2.3/src/sucrack.c:164:15: [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). bsize = atoi(optarg); data/sucrack-1.2.3/src/dictionary.c:207:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(word, out_next->word, DICT_MAX_WORD_SIZE); data/sucrack-1.2.3/src/dictionary.c:262:9: [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). l = strlen(w); data/sucrack-1.2.3/src/dictionary.c:350:9: [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(word) > 0) { data/sucrack-1.2.3/src/dictionary.c:351: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 (word[strlen(word) - 1] == '\n') { data/sucrack-1.2.3/src/dictionary.c:352: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). word[strlen(word) - 1] = '\0'; data/sucrack-1.2.3/src/dictionary.c:358:2: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(DICT_UPDATE_WAIT_US); data/sucrack-1.2.3/src/dictionary.c:360:19: [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). dstat.bnum += strlen(word); data/sucrack-1.2.3/src/dictionary.c:385:7: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(DICT_UPDATE_WAIT_US); data/sucrack-1.2.3/src/dictionary.c:388:18: [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). dstat.rbnum += strlen(aw); data/sucrack-1.2.3/src/dictionary.c:405:2: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(100); data/sucrack-1.2.3/src/pty.c:52:17: [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). mp = mdev + strlen(PTY_DEVICE_NAME) - 2; data/sucrack-1.2.3/src/pty.c:55:17: [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). sp = sdev + strlen(TTY_DEVICE_NAME) - 2; data/sucrack-1.2.3/src/pty.c:57:23: [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). for (dx = 0; dx < strlen(cmap[0]); dx++) { data/sucrack-1.2.3/src/pty.c:59: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). for (dy = 0; dy < strlen(cmap[1]); dy++) { data/sucrack-1.2.3/src/rules.c:51:9: [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). out[strlen(out) - 1] = toupper(out[strlen(out) - 1]); data/sucrack-1.2.3/src/rules.c:51: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). out[strlen(out) - 1] = toupper(out[strlen(out) - 1]); data/sucrack-1.2.3/src/rules.c:87:9: [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). out[strlen(out) - 1] = tolower(out[strlen(out) - 1]); data/sucrack-1.2.3/src/rules.c:87: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). out[strlen(out) - 1] = tolower(out[strlen(out) - 1]); data/sucrack-1.2.3/src/stat.c:92:69: [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). printf("\33[0;%iH\33[1m%s\33[0m\n\n\n", (ws.ws_col / 2) - ((strlen(SUCRACK_TITLE) + 7)/ 2), SUCRACK_TITLE); data/sucrack-1.2.3/src/su.c:74:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). clen = read(fd, buf, BUSY_READ_BUFSZ); data/sucrack-1.2.3/src/su.c:78:9: [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(tbuf) + clen) >= tlen) { data/sucrack-1.2.3/src/su.c:82:4: [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(tbuf, buf, clen); data/sucrack-1.2.3/src/su.c:138:2: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(10 * f); data/sucrack-1.2.3/src/su.c:139:28: [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). rs = write(mfd, send_buf, strlen(send_buf)); data/sucrack-1.2.3/src/su.c:150: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). if (strncmp(resp, auth_success, strlen(auth_success)) == 0) { data/sucrack-1.2.3/src/su.c:207:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(su[0], path, 64); data/sucrack-1.2.3/src/su.c:208:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(su[1], user, 64); data/sucrack-1.2.3/src/su.c:209:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(su[2], "-c", 64); data/sucrack-1.2.3/src/su.c:222:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(su[1], user, SU_MAX_USERNAME_LEN); data/sucrack-1.2.3/src/util.c:69:9: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). return getchar(); data/sucrack-1.2.3/src/worker.c:169:6: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(100); ANALYSIS SUMMARY: Hits = 59 Lines analyzed = 2352 in approximately 0.10 seconds (23325 lines/second) Physical Source Lines of Code (SLOC) = 1445 Hits@level = [0] 75 [1] 31 [2] 16 [3] 4 [4] 8 [5] 0 Hits@level+ = [0+] 134 [1+] 59 [2+] 28 [3+] 12 [4+] 8 [5+] 0 Hits/KSLOC@level+ = [0+] 92.7336 [1+] 40.8304 [2+] 19.3772 [3+] 8.3045 [4+] 5.53633 [5+] 0 Dot directories skipped = 1 (--followdotdir overrides) 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.