Multiple Vendor BSD fstat Format String Vulnerability

fstat is a program shipped with BSD unix variants that is used to list the open files on a system. It is installed sgid kmem so it can access information about open files from the kernel memory structures.

A user definable environment variable (PWD, parent working directory) is passed as the only argument to a *printf() function within fstat. As a result, it is possible for a user to exec fstat with a value for the PWD variable that contains malicious format specifiers. These format specifiers could be layed out in the environment variable in a way that causes the *printf function interpreting them to overwrite certain bytes on the stack (like those that the return address of the function called is composed of) and manipulate the flow of execution.

An attacker, upon successful exploitation of this vulnerability, would inherit the effective privileges of the running fstat program: egid kmem. Further compromise for an experienced hacker would be trivial.

It is likely that this vulnerability affects all modern BSDs, though as of yet only OpenBSD is confirmed.


 

Privacy Statement
Copyright 2010, SecurityFocus