Bug 134874

Summary: CAN-2004-1070 binfmt_elf loader vulnerabilities (CAN-2004-1071 CAN-2004-1072 CAN-2004-1073)
Product: Red Hat Enterprise Linux 3 Reporter: Josh Bressers <bressers>
Component: kernelAssignee: Dave Anderson <anderson>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: high Docs Contact:
Priority: medium    
Version: 3.0CC: jbaron, pere, peterm, petrides, redhat-bugzilla, riel, security-response-team
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: impact=important,embargo=20041110:12
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-12-02 11:42:07 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:
Attachments:
Description Flags
isec.pl advisory
none
Current patch being kicked around vendor-sec.
none
RHEL3 patch, adapted from attached 2.6 patch
none
RHEL3 patch adapted from final 2.6 patch none

Description Josh Bressers 2004-10-06 21:12:20 UTC
Paul Starzetz has repoted to vendor-sec an issue in the Linux ELF
binary loader while handling setuid binaries.  This could lead to
local privilege escalation.

This issue is fairly complicated, I'll attach the advisory which goes
into detail.

This issue is currently embargoed with no date set.

Comment 1 Josh Bressers 2004-10-06 21:14:36 UTC
Created attachment 104867 [details]
isec.pl advisory

Comment 2 Josh Bressers 2004-10-06 21:19:11 UTC
Created attachment 104868 [details]
Current patch being kicked around vendor-sec.

I have no doubt this patch needs some work.  It's against 2.6.

Comment 3 Dave Anderson 2004-10-07 20:19:40 UTC
Created attachment 104915 [details]
RHEL3 patch, adapted from attached 2.6 patch

Comment 4 Dave Anderson 2004-10-07 20:26:38 UTC
The patch was easily adapted to RHEL's 2.4.21-based kernel.

I've run the attached test program, which appears to want the
name of a setuid program as an argument.  However, I get the
same behaviour with and without the patch; i.e., I cannot determine
from the advisory's description how exactly the success/failure
of the patch can be ascertained.

Comment 7 Josh Bressers 2004-11-10 14:24:35 UTC
Removing embargo.

Comment 8 Dave Anderson 2004-11-10 14:29:47 UTC
Still needinfo as per comment #4.

Comment 9 Mark J. Cox 2004-11-10 15:23:10 UTC
Final advisory:
http://isec.pl/vulnerabilities/isec-0017-binfmt_elf.txt

Comment 10 Mark J. Cox 2004-11-10 15:59:57 UTC
I believe this issue should be impact=important not moderate, although
it has not been proved that this can allow an easy local privilege
escalation we don't want our rating to be based on the unknown threat
level.

Comment 11 Dave Anderson 2004-11-10 16:20:30 UTC
The final advisory has an additional issue #4 that isn't addressed
in the patch supplied in comment #2.  I'm presuming that the idea
is that the kmalloc() should request elf->ppnt->p_filesz + 1 bytes
and then ensure that the last byte is a NULL?

 4) the loaded interpreter section can contain an interpreter name
    string without the terminating NULL:

518:     elf_interpreter = (char *) kmalloc(elf_ppnt->p_filesz,
		GFP_KERNEL);       

But then it goes on to say:

4) This bug leads to internal kernel file system functions beeing
called with an argument string  exceeding  the  maximum  path  size 
in length (PATH_MAX). It is not clear if this condition is
exploitable.

That doesn't apply to our RHEL3 kernel, because it does
make an explicit check for > PATH_MAX before the kmalloc:

        if (elf_ppnt->p_filesz > PATH_MAX)
                goto out_free_file;
        elf_interpreter = (char *) kmalloc(elf_ppnt->p_filesz,
                GFP_KERNEL);

(However, I see that AS2.1 does not make that PATH_MAX check)
                                                          
And my question regarding the testing is that when I run the
test program in the advisory, I get the same outward results
both with and without the patch applied.  

In any case, is there an updated patch that you are aware of?


Comment 15 Dave Anderson 2004-11-11 13:46:26 UTC
Outstanding!  Looks like the first one with the additional
NULL-byte stuffing for the additional problem.

Thanks Mark -- I really appreciate the upstream digging!
I'll rework it again for RHEL3.

Comment 17 Dave Anderson 2004-11-12 21:28:30 UTC
Created attachment 106607 [details]
RHEL3 patch adapted from final 2.6 patch

Comment 19 Ernie Petrides 2004-11-13 00:14:54 UTC
Josh or Mark, is there a CVE # associated with this?


Comment 20 Josh Bressers 2004-11-13 01:18:11 UTC
Sadly, there is not.  I'll request one.

Comment 21 Ernie Petrides 2004-11-13 01:23:58 UTC
Josh, don't bother.  I just asked so that I would know how to
update the U4 kernel erratum.  (There's no need to create extra
work for ourselves.)


Comment 22 Ernie Petrides 2004-11-13 02:13:55 UTC
A fix for this problem has just been committed to the RHEL3 U4
patch pool this evening (in kernel version 2.4.21-25.EL).


Comment 23 Ernie Petrides 2004-11-25 01:31:44 UTC
The fix for this problem has also been committed to the RHEL3 E4
patch pool this evening (in kernel version 2.4.21-20.0.1.EL).


Comment 24 Josh Bressers 2004-11-29 19:14:27 UTC
Here is the CVE information for this issue.

>>20040920 binfmt_elf loader vulnerabilities
>>
>>      2.4.27 and earlier, 2.6.9 and earlier are vulnerable
>>
>>      http://www.isec.pl/vulnerabilities/isec-0017-binfmt_elf.txt
>>
>>      1&3 Missing return value check may allow memory layout
>>      modification of setuid binaries
  CAN-2004-1070 - missing return value check

>>      2. Incorrect error handling can lead to incorrect mapped image
>>      in memory
  CAN-2004-1071 - incorrect error handling

>>      4. Possible to exceed to the maximum path size of an
>>      interpreter name string which may lead to a denial of service
  CAN-2004-1072 - exceed maximum path size for interpreter name string

>>      5. open_exec() allows reading of non-readable ELF binaries
  CAN-2004-1073 - open_exec reading non-readable ELF binaries

Comment 25 Mark J. Cox 2004-12-02 11:42:07 UTC
http://rhn.redhat.com/errata/RHSA-2004-549.html