Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Security Report: 16 high severity findings, 16 total findings [develop] #19

Open
1 task
mend-for-github-com bot opened this issue Jan 15, 2025 · 0 comments
Open
1 task
Labels
Mend: code security findings Code security findings detected by Mend

Comments

@mend-for-github-com
Copy link
Contributor

Code Security Report

Scan Metadata

Latest Scan: 2025-01-15 05:07pm
Total Findings: 16 | New Findings: 0 | Resolved Findings: 0
Tested Project Files: 451
Detected Programming Languages: 2 (C/C++ (Beta), Python*)

  • Check this box to manually trigger a scan

Most Relevant Findings

The list below presents the 10 most relevant findings that need your attention. To view information on the remaining findings, navigate to the Mend Application.

SeverityVulnerability TypeCWEFileData FlowsDetected
HighOut of Buffer Bounds Write

CWE-787

bcc_perf_map.c:39

12025-01-15 05:11pm
Vulnerable Code

int bcc_perf_map_nstgid(int pid) {
char status_path[64];
FILE *status;
snprintf(status_path, sizeof(status_path), "/proc/%d/status", pid);

1 Data Flow/s detected

snprintf(status_path, sizeof(status_path), "/proc/%d/status", pid);

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Out of Buffer Bounds Write Training

● Videos

   ▪ Secure Code Warrior Out of Buffer Bounds Write Video

 
HighOut of Buffer Bounds Write

CWE-787

libbpf.c:1220

12025-01-15 05:11pm
Vulnerable Code

bcc/src/cc/libbpf.c

Lines 1215 to 1220 in 6090e9c

if (kfd < 0) {
fprintf(stderr, "open(%s): %s\n", buf, strerror(errno));
goto error;
}
res = snprintf(buf, sizeof(buf), "-:%ss/%s_bcc_%d", event_type, ev_name, getpid());

1 Data Flow/s detected

res = snprintf(buf, sizeof(buf), "-:%ss/%s_bcc_%d", event_type, ev_name, getpid());

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Out of Buffer Bounds Write Training

● Videos

   ▪ Secure Code Warrior Out of Buffer Bounds Write Video

 
HighOut of Buffer Bounds Write

CWE-787

libbpf.c:1188

12025-01-15 05:11pm
Vulnerable Code

bcc/src/cc/libbpf.c

Lines 1183 to 1188 in 6090e9c

* For [k,u]probe created with perf_event_open (on newer kernel), it is
* not necessary to clean it up in [k,u]probe_events. We first look up
* the %s_bcc_%d line in [k,u]probe_events. If the event is not found,
* it is safe to skip the cleaning up process (write -:... to the file).
*/
snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/%s_events", event_type);

1 Data Flow/s detected

snprintf(buf, sizeof(buf), "/sys/kernel/debug/tracing/%s_events", event_type);

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Out of Buffer Bounds Write Training

● Videos

   ▪ Secure Code Warrior Out of Buffer Bounds Write Video

 
HighOut of Buffer Bounds Write

CWE-787

trace_helpers.c:301

12025-01-15 05:11pm
Vulnerable Code

if (!gelf_getshdr(section, &header))
continue;
name = elf_strptr(e, stridx, header.sh_name);
if (name && !strcmp(name, ".text")) {
*addr = (uint64_t)header.sh_addr;

1 Data Flow/s detected

*addr = (uint64_t)header.sh_addr;

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Out of Buffer Bounds Write Training

● Videos

   ▪ Secure Code Warrior Out of Buffer Bounds Write Video

 
HighOut of Buffer Bounds Write

CWE-787

libbpf.c:878

12025-01-15 05:11pm
Vulnerable Code

bcc/src/cc/libbpf.c

Lines 873 to 878 in 6090e9c

{
int fd;
int ret;
char buf[PATH_MAX];
ret = snprintf(buf, sizeof(buf), PMU_RETPROBE_FILE, event_type);

1 Data Flow/s detected

ret = snprintf(buf, sizeof(buf), PMU_RETPROBE_FILE, event_type);

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Out of Buffer Bounds Write Training

● Videos

   ▪ Secure Code Warrior Out of Buffer Bounds Write Video

 
HighOut of Buffer Bounds Write

CWE-787

libbpf.c:1195

12025-01-15 05:11pm
Vulnerable Code

bcc/src/cc/libbpf.c

Lines 1190 to 1195 in 6090e9c

if (!fp) {
fprintf(stderr, "open(%s): %s\n", buf, strerror(errno));
goto error;
}
res = snprintf(buf, sizeof(buf), "%ss/%s_bcc_%d", event_type, ev_name, getpid());

1 Data Flow/s detected

res = snprintf(buf, sizeof(buf), "%ss/%s_bcc_%d", event_type, ev_name, getpid());

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Out of Buffer Bounds Write Training

● Videos

   ▪ Secure Code Warrior Out of Buffer Bounds Write Video

 
HighOut of Buffer Bounds Write

CWE-787

bcc_proc.c:449

12025-01-15 05:11pm
Vulnerable Code

bcc/src/cc/bcc_proc.c

Lines 444 to 449 in 6090e9c

while (isspace(mapname[0])) mapname++;
if (strstr(mapname, ".so") && (strstr(mapname, search1) ||
strstr(mapname, search2))) {
found = true;

1 Data Flow/s detected

found = true;

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Out of Buffer Bounds Write Training

● Videos

   ▪ Secure Code Warrior Out of Buffer Bounds Write Video

 
HighPath/Directory Traversal

CWE-22

libbpf.c:1030

12025-01-15 05:11pm
Vulnerable Code

bcc/src/cc/libbpf.c

Lines 1025 to 1030 in 6090e9c

int kfd = -1, res = -1;
char ev_alias[256];
bool is_kprobe = strncmp("kprobe", event_type, 6) == 0;
snprintf(buf, PATH_MAX, "/sys/kernel/debug/tracing/%s_events", event_type);
kfd = open(buf, O_WRONLY | O_APPEND, 0);

1 Data Flow/s detected

if (bytes <= 0 || bytes >= sizeof(buf)) {

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Path/Directory Traversal Training

● Videos

   ▪ Secure Code Warrior Path/Directory Traversal Video

● Further Reading

   ▪ OWASP Path Traversal

   ▪ OWASP Input Validation Cheat Sheet

 
HighOut of Buffer Bounds Write

CWE-787

libbpf.c:971

12025-01-15 05:11pm
Vulnerable Code

bcc/src/cc/libbpf.c

Lines 966 to 971 in 6090e9c

char buf[PATH_MAX];
struct perf_event_attr attr = {};
// Caller did not provided a valid Perf Event FD. Create one with the debugfs
// event path provided.
if (*pfd < 0) {
snprintf(buf, sizeof(buf), "%s/id", event_path);

1 Data Flow/s detected

snprintf(buf, sizeof(buf), "%s/id", event_path);

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Out of Buffer Bounds Write Training

● Videos

   ▪ Secure Code Warrior Out of Buffer Bounds Write Video

 
HighPath/Directory Traversal

CWE-22

libbpf.c:1029

12025-01-15 05:11pm
Vulnerable Code

bcc/src/cc/libbpf.c

Lines 1024 to 1029 in 6090e9c

{
int kfd = -1, res = -1;
char ev_alias[256];
bool is_kprobe = strncmp("kprobe", event_type, 6) == 0;
snprintf(buf, PATH_MAX, "/sys/kernel/debug/tracing/%s_events", event_type);

1 Data Flow/s detected

if (bytes <= 0 || bytes >= sizeof(buf)) {

Secure Code Warrior Training Material

● Training

   ▪ Secure Code Warrior Path/Directory Traversal Training

● Videos

   ▪ Secure Code Warrior Path/Directory Traversal Video

● Further Reading

   ▪ OWASP Path Traversal

   ▪ OWASP Input Validation Cheat Sheet

Findings Overview

Severity Vulnerability Type CWE Language Count
High Buffer Overflow CWE-121 C/C++ (Beta) 2
High Out of Buffer Bounds Write CWE-787 C/C++ (Beta) 10
High Use After Free CWE-416 C/C++ (Beta) 1
High Double Free CWE-415 C/C++ (Beta) 1
High Path/Directory Traversal CWE-22 C/C++ (Beta) 2
@mend-for-github-com mend-for-github-com bot added the Mend: code security findings Code security findings detected by Mend label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mend: code security findings Code security findings detected by Mend
Development

No branches or pull requests

0 participants