Bug 697975 (CVE-2011-1749) - CVE-2011-1749 nfs-utils: mount.nfs fails to anticipate RLIMIT_FSIZE
Summary: CVE-2011-1749 nfs-utils: mount.nfs fails to anticipate RLIMIT_FSIZE
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2011-1749
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 697977 697978 697979 697980 697981 697982
Blocks: 716955 742493
TreeView+ depends on / blocked
 
Reported: 2011-04-19 19:45 UTC by Vincent Danen
Modified: 2019-09-29 12:44 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-21 08:24:31 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:1534 normal SHIPPED_LIVE Low: nfs-utils security, bug fix, and enhancement update 2011-12-06 01:01:48 UTC
Red Hat Product Errata RHSA-2012:0310 normal SHIPPED_LIVE Low: nfs-utils security, bug fix, and enhancement update 2012-02-21 07:25:03 UTC

Description Vincent Danen 2011-04-19 19:45:20 UTC
It was found that mount.nfs suffers from the same flaw as other mount helpers (see CVE-2011-1089).  Instead of using addmntent(), nfs-utils implements its own similar function (nfs_addmntent()) which also fails to anticipate whether resource limits would interfere with correctly writing to /etc/mtab.  A local user could use this to trigger corruption of the /etc/mtab file via a process with a small RLIMIT_FSIZE value.

In nfs-utils-1.2.3/support/nfs/nfs_mntent.c:

126 int
127 nfs_addmntent (mntFILE *mfp, struct mntent *mnt) {
128     char *m1, *m2, *m3, *m4;
129     int res;
130 
131     if (fseek (mfp->mntent_fp, 0, SEEK_END))
132         return 1;           /* failure */
133 
134     m1 = mangle(mnt->mnt_fsname);
135     m2 = mangle(mnt->mnt_dir);
136     m3 = mangle(mnt->mnt_type);
137     m4 = mangle(mnt->mnt_opts);
138 
139     res = fprintf (mfp->mntent_fp, "%s %s %s %s %d %d\n",
140                m1, m2, m3, m4, mnt->mnt_freq, mnt->mnt_passno);
141 
142     free(m1);
143     free(m2);
144     free(m3);
145     free(m4);
146     return (res < 0) ? 1 : 0;
147 }

The above function should use fflush() and return failure based on the success of the fflush() call, to ensure it is fully written prior to updating /etc/mtab.  Perhaps something like:

146     return (res < 0) ? 1 : ((fflush(mfp->mntent_fp) == 0) ? 0 : 1);

Comment 2 Vincent Danen 2011-04-19 19:51:29 UTC
Created nfs-utils tracking bugs for this issue

Affects: fedora-all [bug 697982]

Comment 3 Jeff Layton 2011-04-19 20:02:57 UTC
> 146     return (res < 0) ? 1 : ((fflush(mfp->mntent_fp) == 0) ? 0 : 1);

Dear god, no. There's no reason to do all of that one one line.

If I'm reading it right though, the logic looks correct, but let's do something that's a little easier to read (and debug...)

Comment 5 Vincent Danen 2011-04-19 21:32:18 UTC
Looks like this does not affect the version in RHEL4 as I can't see any mention of addmntent() or nfs_addmntent() anywhere (the only reference to mtab seems to be in nfs-utils-1.0.6/utils/rquotad/mntent.h).

Jeff, can you confirm whether or not this is an issue for RHEL4?  Thanks.

Comment 6 Vincent Danen 2011-04-26 15:27:57 UTC
This was assigned CVE-2011-1749.

Comment 11 Vincent Danen 2011-04-27 16:31:32 UTC
Statement:

This issue did not affect the versions of nfs-utils as shipped with Red Hat Enterprise Linux 4 as it did not include include mount.nfs. It was addressed in Red Hat Enterprise Linux 5 and 6 via RHSA-2012:0310 and RHSA-2011:1534 respectively.

Comment 14 errata-xmlrpc 2011-12-06 18:53:38 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 6

Via RHSA-2011:1534 https://rhn.redhat.com/errata/RHSA-2011-1534.html

Comment 19 errata-xmlrpc 2012-02-21 03:23:34 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5

Via RHSA-2012:0310 https://rhn.redhat.com/errata/RHSA-2012-0310.html


Note You need to log in before you can comment on or make changes to this bug.