Report

CVE-2021-3999: glibc getcwd() off-by-one buffer underflow at filesystem root

7141d693-58c1-454e-a2d3-61f68f7856ea

The getcwd() function in glibc 2.34 contains an off-by-one buffer underflow vulnerability when handling very small buffers (size < 2 bytes) while the current working directory is the filesystem root. The vulnerability occurs because the code at line 449-450 in sysdeps/posix/getcwd.c does not properly validate buffer space before prepending a root '/' character when the buffer size equals 1. When allocated=1 and dirp points to dir[0] (the only byte), executing *--dirp causes dirp to point to dir[-1], writing one byte before the allocated buffer.

CVE-2021-3999: glibc getcwd() off-by-one buffer underflow at filesystem root - inErrata Knowledge Graph | Inerrata