Security Experts:

Remote Code Execution Flaw Impacts E2fsprogs Filesystem Utility

An out-of-bounds write bug in the E2fsprogs filesystem utility could lead to remote code execution, Cisco Talos security researchers reveal.

E2fsprogs is a set of utilities designed for interaction with ext2, ext3 and ext4 filesystems. Considered essential for Linux and Unix-like operating systems, the software ships by default on most Linux distributions.

One of E2fsprogs’ components is the e2fsck binary, which aims to fix corrupted filesystems, and which Cisco Talos found to contain the out-of-bounds write flaw.

The implementation of directories in ext2, 3 and 4 involves the use of hash trees for the unique mapping of files within a directory. The hash entries for the hash tree are contained within hash_entry struct, while the number of hash entries is contained within num_array.

To maintain the integrity and assumptions of a hash table, all the entries should be unique, a requirement that e2fsck enforces by appending the second file name in a collision with {~0, ~1, ..., ~n}, depending on the number of duplicates, Talos says.

A temporary stack buffer is used to temporarily store mutated names to write them to the disk later on, and the utility then iterates over each hash_entry struct. When a collision is met, the length of the current file name is extracted and then the mutate_name function is used to perform changes.

What the security researchers discovered was that the process was prone to an out-of-bounds stack. The issue resides in the E2fsprogs e2fsck rehash.c mutate_name() function, resulting in the directory rehashing functionality being abused for code execution.

A specially crafted ext4 directory could be used to cause an out-of-bounds write on the stack, leading to code execution. In order to trigger the vulnerability, the attacker would need to corrupt a partition, Talos’ researchers explain.

On 64-bit systems, exploitation is very unlikely, because the stack is not big enough and a user-controlled method for expanding the stack is required, the researchers explain.

On 32-bit versions, on the other hand, the end result is more dependent on the binary itself and on the manner it was compiled, Talos says.

Tracked as CVE-2019-5188 and featuring a CVSS score of 7.5, the vulnerability was disclosed to the vendor on December 18, 2019, and acknowledged on December 20. Versions 1.43.3 - 1.45.3 of E2fsprogs were found affected by this vulnerability. An update that patches the flaw was released this week.

Related: Code Execution Vulnerabilities Patched in Accusoft ImageGear

Related: Cisco Finds 11 Vulnerabilities in Schneider Electric Modicon Controllers

view counter