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/reptyr-0.6.2/platform/freebsd/arch/amd64.h Examining data/reptyr-0.6.2/platform/freebsd/arch/arm.h Examining data/reptyr-0.6.2/platform/freebsd/arch/default-syscalls.h Examining data/reptyr-0.6.2/platform/freebsd/arch/i386.h Examining data/reptyr-0.6.2/platform/freebsd/arch/x86_common.h Examining data/reptyr-0.6.2/platform/freebsd/freebsd.c Examining data/reptyr-0.6.2/platform/freebsd/freebsd.h Examining data/reptyr-0.6.2/platform/freebsd/freebsd_ptrace.c Examining data/reptyr-0.6.2/platform/linux/arch/amd64.h Examining data/reptyr-0.6.2/platform/linux/arch/arm.h Examining data/reptyr-0.6.2/platform/linux/arch/default-syscalls.h Examining data/reptyr-0.6.2/platform/linux/arch/i386.h Examining data/reptyr-0.6.2/platform/linux/arch/x86_common.h Examining data/reptyr-0.6.2/platform/linux/linux.c Examining data/reptyr-0.6.2/platform/linux/linux_ptrace.c Examining data/reptyr-0.6.2/platform/linux/linux.h Examining data/reptyr-0.6.2/platform/platform.h Examining data/reptyr-0.6.2/ptrace.h Examining data/reptyr-0.6.2/reallocarray.c Examining data/reptyr-0.6.2/reallocarray.h Examining data/reptyr-0.6.2/reptyr.c Examining data/reptyr-0.6.2/reptyr.h Examining data/reptyr-0.6.2/test/victim.c Examining data/reptyr-0.6.2/attach.c FINAL RESULTS: data/reptyr-0.6.2/attach.c:390: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(steal->addr_un.sun_path, steal->target_stat.uid, steal->target_stat.gid) < 0) data/reptyr-0.6.2/attach.c:392: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(steal->tmpdir, steal->target_stat.uid, steal->target_stat.gid) < 0) data/reptyr-0.6.2/reptyr.c:45: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, msg, ap); data/reptyr-0.6.2/reptyr.c:283:17: [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. execvp(argv[2], argv + 2); data/reptyr-0.6.2/reptyr.h:34:40: [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. #define __printf __attribute__((format(printf, 1, 2))) data/reptyr-0.6.2/reptyr.c:191:19: [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 ((opt = getopt(argc, argv, "hlLsTvV")) != -1) { data/reptyr-0.6.2/attach.c:179:15: [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 ((fd = open(pty, O_RDONLY)) < 0) data/reptyr-0.6.2/attach.c:248: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 stat_path[PATH_MAX]; data/reptyr-0.6.2/attach.c:267:14: [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). statfd = open(stat_path, O_RDONLY); data/reptyr-0.6.2/attach.c:305:35: [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). child_fd = do_syscall(&child, open, data/reptyr-0.6.2/attach.c:373:5: [2] (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). Risk is low because the source is a constant string. strcpy(steal->tmpdir, "/tmp/reptyr.XXXXXX"); data/reptyr-0.6.2/attach.c:424:18: [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[CMSG_SPACE(sizeof(int))]; data/reptyr-0.6.2/attach.c:435: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(CMSG_DATA(cm), &steal->master_fds.fds[0], sizeof(int)); data/reptyr-0.6.2/attach.c:511:44: [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 = do_syscall(&steal->child, open, steal->child_scratch, O_RDWR, 0, 0, 0, 0); data/reptyr-0.6.2/platform/freebsd/arch/default-syscalls.h:26:8: [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). SC(open), data/reptyr-0.6.2/platform/freebsd/freebsd.c:98: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 errbuf[_POSIX2_LINE_MAX]; data/reptyr-0.6.2/platform/freebsd/freebsd.c:200: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). fd = open(fst->fs_path, O_RDONLY); data/reptyr-0.6.2/platform/freebsd/freebsd.c:244: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(&d->regs, &s->regs, sizeof(s->regs)); data/reptyr-0.6.2/platform/freebsd/freebsd_ptrace.c:270: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(&scratch, src, n); data/reptyr-0.6.2/platform/freebsd/freebsd_ptrace.c:284: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(dst, &scratch, min(n, sizeof(int))); data/reptyr-0.6.2/platform/freebsd/freebsd_ptrace.c:315:11: [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). pid = atoi(argv[1]); data/reptyr-0.6.2/platform/linux/arch/default-syscalls.h:26:8: [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). SC(open), data/reptyr-0.6.2/platform/linux/linux.c:32: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[1024]; data/reptyr-0.6.2/platform/linux/linux.c:60: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 stat_path[PATH_MAX]; data/reptyr-0.6.2/platform/linux/linux.c:65:14: [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). statfd = open(stat_path, O_RDONLY); data/reptyr-0.6.2/platform/linux/linux.c:96:14: [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("/proc/sys/kernel/yama/ptrace_scope", O_RDONLY); data/reptyr-0.6.2/platform/linux/linux.c:98: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 buf[256]; data/reptyr-0.6.2/platform/linux/linux.c:103:18: [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)) { data/reptyr-0.6.2/platform/linux/linux.c:148:17: [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(pid_stat.comm, "???", 4); data/reptyr-0.6.2/platform/linux/linux.c:177: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[PATH_MAX]; data/reptyr-0.6.2/platform/linux/linux.c:213:37: [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 (fd_array_push(&fds, atoi(d->d_name)) != 0) { data/reptyr-0.6.2/platform/linux/linux.c:257: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[PATH_MAX]; data/reptyr-0.6.2/platform/linux/linux.c:275:26: [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). atoi(d->d_name), data/reptyr-0.6.2/platform/linux/linux.c:291:44: [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). debug("found a master fd: %d", atoi(d->d_name)); data/reptyr-0.6.2/platform/linux/linux.c:292:51: [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 (fd_array_push(&steal->master_fds, atoi(d->d_name)) != 0) { data/reptyr-0.6.2/platform/linux/linux.c:307: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). return open("/dev/ptmx", O_RDWR | O_NOCTTY); data/reptyr-0.6.2/platform/linux/linux.c:312: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[PATH_MAX]; data/reptyr-0.6.2/platform/linux/linux.c:320:19: [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 ((fd = open(buf, O_RDONLY)) < 0) { data/reptyr-0.6.2/platform/linux/linux.c:365: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(&d->user, &s->user, sizeof(s->user)); data/reptyr-0.6.2/platform/linux/linux_ptrace.c:270: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(&scratch, src, n); data/reptyr-0.6.2/platform/linux/linux_ptrace.c:284: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(dst, &scratch, min(n, sizeof(unsigned long))); data/reptyr-0.6.2/platform/linux/linux_ptrace.c:315:11: [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). pid = atoi(argv[1]); data/reptyr-0.6.2/platform/platform.h:44: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 comm[TASK_COMM_LENGTH+1]; data/reptyr-0.6.2/platform/platform.h:58: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 tmpdir[PATH_MAX]; data/reptyr-0.6.2/reptyr.c:124: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/reptyr-0.6.2/reptyr.c:274: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). f = open(ptsname(pty), O_RDONLY, 0); data/reptyr-0.6.2/reptyr.c:277: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). f = open(ptsname(pty), O_WRONLY, 0); data/reptyr-0.6.2/attach.c:299: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). if (ptrace_memcpy_to_child(&child, scratch_page, pty, strlen(pty) + 1)) { data/reptyr-0.6.2/platform/linux/linux.c:36:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(statfd, buf, sizeof buf) < 0) data/reptyr-0.6.2/platform/linux/linux.c:100:13: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). n = read(fd, buf, sizeof buf); data/reptyr-0.6.2/reptyr.c:150:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). count = read(0, buf, sizeof buf); data/reptyr-0.6.2/reptyr.c:156:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). count = read(pty, buf, sizeof buf); ANALYSIS SUMMARY: Hits = 52 Lines analyzed = 3222 in approximately 0.26 seconds (12547 lines/second) Physical Source Lines of Code (SLOC) = 2264 Hits@level = [0] 42 [1] 5 [2] 41 [3] 1 [4] 3 [5] 2 Hits@level+ = [0+] 94 [1+] 52 [2+] 47 [3+] 6 [4+] 5 [5+] 2 Hits/KSLOC@level+ = [0+] 41.5194 [1+] 22.9682 [2+] 20.7597 [3+] 2.65018 [4+] 2.20848 [5+] 0.883392 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.