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/rkt-1.30.0+dfsg1/stage1/diagnostic/diagnostic-util.c Examining data/rkt-1.30.0+dfsg1/stage1/diagnostic/diagnostic-util.h Examining data/rkt-1.30.0+dfsg1/stage1/diagnostic/diagnostic.c Examining data/rkt-1.30.0+dfsg1/stage1/diagnostic/elf.h Examining data/rkt-1.30.0+dfsg1/stage1/enter/enter.c Examining data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c Examining data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c FINAL RESULTS: data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:214:13: [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. pexit_if(readlink(link_path, target, sizeof(target)) == -1, data/rkt-1.30.0+dfsg1/stage1/enter/enter.c:44:3: [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. fprintf(stderr, _fmt "\n", ##_args); \ data/rkt-1.30.0+dfsg1/stage1/enter/enter.c:171:12: [4] (shell) execv: 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. pexit_if(execv(args[0], args) == -1, data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:41:7: [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(keep_env_file, F_OK)) return; data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:216:11: [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. pexit_if(execvp(exe, args) == -1 && data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:153:6: [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("/proc/1/uid_map", F_OK) == 0) { data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:162:8: [4] (buffer) fscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. k = fscanf(f, "%"PRIu32" %"PRIu32" %"PRIu32, data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:165:8: [4] (buffer) fscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. k = fscanf(f, "%"PRIu16" %"PRIu16" %"PRIu16, data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:383:7: [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(from, F_OK) != 0) data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:416:7: [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(mnt->source, F_OK) != 0) data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:418:34: [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( mnt->skip_if_dst_exists && access(to, F_OK) == 0) data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:420:7: [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(to, F_OK) != 0) { data/rkt-1.30.0+dfsg1/stage1/diagnostic/diagnostic.c:27:11: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. pexit_if(chroot(root) == -1, "Chroot \"%s\" failed", root); data/rkt-1.30.0+dfsg1/stage1/enter/enter.c:82:7: [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. c = getopt_long(argc, argv, "p:a:", data/rkt-1.30.0+dfsg1/stage1/enter/enter.c:124:11: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. pexit_if(chroot(".") < 0, data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:47:7: [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. v = getenv(*p); data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:93:15: [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 *term = getenv("TERM"); /* useful to keep during entering. */ data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:160:14: [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 ((c = getopt(argc, argv, "e")) != -1) data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:201:11: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. pexit_if(chroot(root) == -1, "Chroot \"%s\" failed", root); data/rkt-1.30.0+dfsg1/stage1/diagnostic/diagnostic-util.c:35:20: [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). pexit_if((fd = open(path, O_RDONLY)) == -1, data/rkt-1.30.0+dfsg1/stage1/enter/enter.c:51:2: [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 path[PATH_MAX]; data/rkt-1.30.0+dfsg1/stage1/enter/enter.c:56: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). pexit_if((fd = open(path, O_RDONLY|O_CLOEXEC)) == -1, data/rkt-1.30.0+dfsg1/stage1/enter/enter.c:89:10: [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(optarg); data/rkt-1.30.0+dfsg1/stage1/enter/enter.c:137: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 root[PATH_MAX]; data/rkt-1.30.0+dfsg1/stage1/enter/enter.c:138: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 env[PATH_MAX]; data/rkt-1.30.0+dfsg1/stage1/enter/enter.c:139: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 *args[ENTEREXEC_ARGV_FWD_OFFSET + argc - optind + 1 /* NULL terminator */]; data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:42:16: [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). pexit_if((f = fopen(keep_env_file, "a")) == NULL, data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:68:16: [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). pexit_if((f = fopen(env_file, "r")) == NULL, data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:191:8: [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). uid = atoi(uid_str); data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:88:2: [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 to[4096]; data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:103:16: [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). pexit_if((f = fopen("/proc/self/mountinfo", "re")) == NULL, data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:158:17: [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). pexit_if((f = fopen("/proc/1/uid_map", "re")) == NULL, data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:204:4: [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 target[4096] = {0,}; data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:314:2: [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 to[4096]; data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:333:11: [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). rootfd = open(root, O_DIRECTORY | O_CLOEXEC); data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:391: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). fd = open(to, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0644); data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:434:11: [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). rootfd = open(root, O_DIRECTORY | O_CLOEXEC); data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:49:51: [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). pexit_if(fprintf(f, "%s=%s%c", *p, v, nul) != (strlen(*p) + strlen(v) + 2), data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:49:64: [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). pexit_if(fprintf(f, "%s=%s%c", *p, v, nul) != (strlen(*p) + strlen(v) + 2), data/rkt-1.30.0+dfsg1/stage1/enterexec/enterexec.c:65:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t read; data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:101:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t read; data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:123: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). if (strncmp(sys_subdir, mountpoint, strlen(sys_subdir)) == 0) { data/rkt-1.30.0+dfsg1/stage1/prepare-app/prepare-app.c:348:2: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(0); ANALYSIS SUMMARY: Hits = 43 Lines analyzed = 1206 in approximately 0.09 seconds (12901 lines/second) Physical Source Lines of Code (SLOC) = 847 Hits@level = [0] 12 [1] 6 [2] 18 [3] 7 [4] 11 [5] 1 Hits@level+ = [0+] 55 [1+] 43 [2+] 37 [3+] 19 [4+] 12 [5+] 1 Hits/KSLOC@level+ = [0+] 64.9351 [1+] 50.7674 [2+] 43.6836 [3+] 22.4321 [4+] 14.1677 [5+] 1.18064 Dot directories skipped = 2 (--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.