Bug 746709 (CVE-2011-3630)

Summary: CVE-2011-3630 hardlink: Multiple stack-based buffer overflows when run on a tree with deeply nested directories
Product: [Other] Security Response Reporter: Jan Lieskovsky <jlieskov>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: jnovy
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-10-28 05:11:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 746715    
Bug Blocks: 746750    

Description Jan Lieskovsky 2011-10-17 15:32:25 UTC
Multiple stack-based buffer overflow flaws were found in the way hardlink, the tool for consolidation of duplicate files via hardlinks, processed directory trees with deeply nested directories. A remote attacker could provide a specially-crafted directory tree, and trick the local user into consolidating it, leading to hardlink executable crash, or, potentially arbitrary code execution with the privileges of the user running the hardlink executable.

References:
[1] http://www.openwall.com/lists/oss-security/2011/10/15/2
[2] https://bugs.gentoo.org/show_bug.cgi?id=387269
[3] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=645516

Proposed patch (applied by the Owl Linux distribution):
[4] http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/hardlink/hardlink.c.diff?r1=1.1;r2=1.2

Comment 1 Jan Lieskovsky 2011-10-17 15:38:45 UTC
These issues affect the versions of the hardlink package, as shipped with Fedora release of 14 and 15. Please schedule an update.

Comment 2 Jan Lieskovsky 2011-10-17 15:41:35 UTC
Created hardlink tracking bugs for this issue

Affects: fedora-all [bug 746715]

Comment 3 Jan Lieskovsky 2011-10-17 15:53:29 UTC
These issues affect the versions of the hardlink package, as shipped with
Red Hat Enterprise Linux 5 and 6.

Comment 4 Jan Lieskovsky 2011-10-20 15:44:24 UTC
The CVE identifier of CVE-2011-3630 has been assigned to these issues:
[5] http://www.openwall.com/lists/oss-security/2011/10/20/6

Comment 6 Huzaifa S. Sidhpurwala 2011-10-21 09:30:11 UTC
This is really not a stack-based overflow, but an BSS-buffer overflow.
It is caught by GCC "Object Size Checking Builtins", __builtin___strcat_chk in this particular case.

The overflow occurs at in hardlink.c at:

309     strcat (nambuf1, "/");

Since the allocated and the current size of the nambuf1 is already known, glibc can very easily determine if the current strcat() function would overflow the buffer and when it does it aborts the program and you can see the message

"*** buffer overflow detected ***: hardlink terminated"

Comment 7 Huzaifa S. Sidhpurwala 2011-10-28 05:06:58 UTC
As mentioned in 
http://www.openwall.com/lists/oss-security/2011/10/22/3

lstat() starts failing with ENAMETOOLONG shortly after the overflow occurs. This limits the size of the overflow, later hardlink crashes with "buffer overflow detectet" message.

Comment 8 Huzaifa S. Sidhpurwala 2011-10-28 05:10:26 UTC
In Red Hat Enterprise Linux 5 and 6, stack based buffer overflows are protected by FORTIFY_SOURCE. Though this is not stack-based buffer-overflow, FORTIFY_SOURCE along with the ability of the kernel to return an error when a exceedingly long path (because of buffer-overflow) is passed to lstat(), limits this vulnerability to just an application crash.

Statement:

This issue does not affect the version of hardlink, as shipped with Red Hat Enterprise Linux 5 and 6.

Comment 9 Huzaifa S. Sidhpurwala 2011-10-28 05:11:00 UTC
This issue does not affect the version of hardlink as shipped with Fedora 14 and 15.

Comment 10 Fedora Update System 2011-11-23 23:27:41 UTC
hardlink-1.0-12.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 11 Fedora Update System 2011-12-11 21:49:56 UTC
hardlink-1.0-12.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.