FreeBSD VuXML: Documenting security issues in FreeBSD and the FreeBSD Ports Collection

FreeBSD -- heap overflow in file(1)

Affected packages
file < 4.21
6.2 <= FreeBSD < 6.2_5
6.1 <= FreeBSD < 6.1_17
5.5 <= FreeBSD < 5.5_13

Details

VuXML ID 8e01ab5b-0949-11dc-8163-000e0c2e438a
Discovery 2007-05-23
Entry 2007-05-23
Modified 2016-08-09

Problem Description:

When writing data into a buffer in the file_printf function, the length of the unused portion of the buffer is not correctly tracked, resulting in a buffer overflow when processing certain files.

Impact:

An attacker who can cause file(1) to be run on a maliciously constructed input can cause file(1) to crash. It may be possible for such an attacker to execute arbitrary code with the privileges of the user running file(1).

The above also applies to any other applications using the libmagic(3) library.

Workaround:

No workaround is available, but systems where file(1) and other libmagic(3)-using applications are never run on untrusted input are not vulnerable.

References

CVE Name CVE-2007-1536
FreeBSD Advisory SA-07:04.file