Skip to content

Four null terminations of buffers written out of range by one in libscap/scan_fds.c

Low
LucaGuerra published GHSA-fr48-vq8h-x796 Feb 9, 2023

Package

falcosecurity/libs

Affected versions

< 0.10.3

Patched versions

0.10.3

Description

Impact

In userspace/libscap/scap_fds.c, some readlink calls were made with SCAP_MAX_PATH_SIZE. The issue is that then these buffer are manually null terminated doing link_name[r] = '\0';, potentially leading to an overflow by one. Given the explanation below, this issue does not look like it is exploitable in Falco ("exploitability: None")

Example:

r = readlink(fname, link_name, SCAP_MAX_PATH_SIZE);

Compiled with -O0, the compiler lets the locals in the order there are declared on the stack, thus we have on the stack (in the order of the stack growth), the return address, a canary, the frame pointer and the end of the link_name. So the line link_name[r] = '\0'; will effectively write a zero out of bound on the frame pointer, which might start with zeros.

So in this precise situation, there are no consequences. But in a different setup, where locals could be located before the buffer, the stack overflow could theoretically lead to issues.

Patches

Upgrade to libs 0.10.3

Workarounds

No

References

Falco Security Audit report, 23-01-1097-LIV by Victor Houal, Laurent Laubin and Mahé Tardy

Severity

Low

CVE ID

No known CVE

Weaknesses