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/singularity-container-3.5.2+ds1/vendor/github.com/mtrmac/gpgme/go_gpgme.c Examining data/singularity-container-3.5.2+ds1/vendor/github.com/mtrmac/gpgme/go_gpgme.h Examining data/singularity-container-3.5.2+ds1/cmd/starter/c/capability.c Examining data/singularity-container-3.5.2+ds1/cmd/starter/c/include/capability.h Examining data/singularity-container-3.5.2+ds1/cmd/starter/c/include/message.h Examining data/singularity-container-3.5.2+ds1/cmd/starter/c/include/securebits.h Examining data/singularity-container-3.5.2+ds1/cmd/starter/c/include/setns.h Examining data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h Examining data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c Examining data/singularity-container-3.5.2+ds1/cmd/starter/c/setns.c Examining data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c Examining data/singularity-container-3.5.2+ds1/docs/2.x-slurm/singularity.c FINAL RESULTS: data/singularity-container-3.5.2+ds1/cmd/starter/c/include/message.h:52:110: [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 _print(int level, const char *function, const char *file, char *format, ...) __attribute__ ((__format__(printf, 4, 5))); data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c:76:9: [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. if (vsnprintf(message, 512, format, args) >= 512) { data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c:146:13: [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. printf("%s" ANSI_COLOR_RESET, message); data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c:148:13: [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. printf("%s%s" ANSI_COLOR_RESET, header_string, message); data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c:150:13: [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, "%s%s" ANSI_COLOR_RESET, header_string, message); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:392:10: [4] (shell) system: 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 ( system(cmd) < 0 ) { data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c:56:37: [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 *messagelevel_string = getenv(MSGLVL_ENV); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:919:25: [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 *pipe_fd_env = getenv("PIPE_EXEC_FD"); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:938:28: [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. if ( geteuid() == 0 && getenv("LOAD_OVERLAY_MODULE") != NULL ) { data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h: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 network[MAX_PATH_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:99: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 mount[MAX_PATH_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:100: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 user[MAX_PATH_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:101: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 ipc[MAX_PATH_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:102: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 uts[MAX_PATH_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:103: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 cgroup[MAX_PATH_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:104: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 pid[MAX_PATH_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:113: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 uidMap[MAX_MAP_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:114: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 gidMap[MAX_MAP_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:118: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 newuidmapPath[MAX_PATH_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:119: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 newgidmapPath[MAX_PATH_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/include/starter.h:162: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 config[MAX_JSON_SIZE]; data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c:50: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 message[512]; data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c:62:28: [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). messagelevel = atoi(messagelevel_string); data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c:77: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(message+496, "(TRUNCATED...)", 15); data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c:119: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 header_string[100]; data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:72: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 alloc[4096] __attribute__((aligned(16))); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:73: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 ptr[0]; data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:346: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). ns_fd = open(nspath, O_RDONLY); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:437:14: [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). map_fp = fopen("setgroups", "w+"); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:448:14: [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). map_fp = fopen("gid_map", "w+"); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:459:14: [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). map_fp = fopen("uid_map", "w+"); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:637: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 proc_auxv = open("/proc/self/auxv", O_RDONLY); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:681: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). if ( ( fd_proc = open("/proc/self/fd", O_RDONLY) ) < 0 ) { data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:693: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). if ( atoi(dirent->d_name) == fd_proc ) { data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:712: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). cv = atoi(dirent->d_name); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:737: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). if ( ( fd_proc = open("/proc/self/fd", O_RDONLY) ) < 0 ) { data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:749: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). fd = atoi(dirent->d_name); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:834:16: [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 = open("/dev/null", O_RDONLY); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:1273: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). cwdfd = open(".", O_RDONLY | O_DIRECTORY); data/singularity-container-3.5.2+ds1/cmd/starter/c/message.c:130: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). funclen = 28 - strlen(function); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:515:13: [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(req.ifr_name, "lo", IFNAMSIZ); data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:647:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ( read(proc_auxv, buffer, 4088) < 0 ) { data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:794:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ( read(fd, &val, sizeof(unsigned char)) <= 0 ) { data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:1004:35: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ( ( sconfig->engine.size = read(pipe_fd, sconfig->engine.config, MAX_JSON_SIZE - 1) ) <= 0 ) { data/singularity-container-3.5.2+ds1/cmd/starter/c/starter.c:1084:13: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(0); ANALYSIS SUMMARY: Hits = 45 Lines analyzed = 2410 in approximately 0.26 seconds (9325 lines/second) Physical Source Lines of Code (SLOC) = 1657 Hits@level = [0] 8 [1] 6 [2] 30 [3] 3 [4] 6 [5] 0 Hits@level+ = [0+] 53 [1+] 45 [2+] 39 [3+] 9 [4+] 6 [5+] 0 Hits/KSLOC@level+ = [0+] 31.9855 [1+] 27.1575 [2+] 23.5365 [3+] 5.4315 [4+] 3.621 [5+] 0 Dot directories skipped = 5 (--followdotdir overrides) Suppressed hits = 4 (use --neverignore to show them) 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.