Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 86257 - sys-fs/e2fsprogs: BLKID_FILE should not be honored in SUID
Summary: sys-fs/e2fsprogs: BLKID_FILE should not be honored in SUID
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: High trivial (vote)
Assignee: Gentoo Security
URL: http://sourceforge.net/projects/e2fsp...
Whiteboard: ~1 [noglsa] koon
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-22 06:31 UTC by Thierry Carrez (RETIRED)
Modified: 2005-06-11 01:18 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
e2fsprogs-1.36-r3.ebuild.diff (e2fsprogs-1.36-r3.ebuild.diff,474 bytes, patch)
2005-03-22 12:26 UTC, solar (RETIRED)
no flags Details | Diff
e2fsprogs-1.36-blkid-cache.patch (e2fsprogs-1.36-blkid-cache.patch,512 bytes, patch)
2005-03-22 12:26 UTC, solar (RETIRED)
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry Carrez (RETIRED) gentoo-dev 2005-03-22 06:31:40 UTC
e2fsprogs 1.37 contains the following fix :

* cache.c (blkid_get_cache): Ignore the BLKID_FILE environment variable if blkid_get_cache() is called from a setuid program.

The official patch is here :
=======================================================
diff -Nru a/lib/blkid/cache.c b/lib/blkid/cache.c
--- a/lib/blkid/cache.c	2005-03-22 07:01:25 -05:00
+++ b/lib/blkid/cache.c	2005-03-22 07:01:25 -05:00
@@ -41,7 +41,7 @@
 
 	if (filename && !strlen(filename))
 		filename = 0;
-	if (!filename)
+	if (!filename && (getuid() == geteuid()))
 		filename = getenv("BLKID_FILE");
 	if (!filename)
 		filename = BLKID_CACHE_FILE;
======================================================

Solar Designer (Openwall) suggested the following Linux-only (better) alternative :

======================================================
 		filename = 0;
 	if (!filename)
- 		filename = getenv("BLKID_FILE");
+ 		filename = __secure_getenv("BLKID_FILE");
 	if (!filename)
 		filename = BLKID_CACHE_FILE;
======================================================

base-system, please advise.
Comment 1 solar (RETIRED) gentoo-dev 2005-03-22 11:46:52 UTC
__secure_getenv() exists only in glibc. It's not portable and we have had problems with patches of his in the past in which __secure_env() crept in.
Comment 2 solar (RETIRED) gentoo-dev 2005-03-22 11:55:15 UTC
How about this?

--- lib/blkid/cache.c.orig	2005-03-22 14:48:19.000000000 -0500
+++ lib/blkid/cache.c	2005-03-22 14:53:08.000000000 -0500
@@ -41,8 +41,13 @@ int blkid_get_cache(blkid_cache *ret_cac
 
 	if (filename && !strlen(filename))
 		filename = 0;
-	if (!filename)
+
+	if (!filename && (getuid() == geteuid()))
+#ifdef __UCLIBC__
 		filename = getenv("BLKID_FILE");
+#else
+		filename = __secure_getenv("BLKID_FILE");
+#endif
 	if (!filename)
 		filename = BLKID_CACHE_FILE;
 	cache->bic_filename = blkid_strdup(filename);
Comment 3 solar (RETIRED) gentoo-dev 2005-03-22 12:26:05 UTC
Created attachment 54173 [details, diff]
e2fsprogs-1.36-r3.ebuild.diff
Comment 4 solar (RETIRED) gentoo-dev 2005-03-22 12:26:58 UTC
Created attachment 54174 [details, diff]
e2fsprogs-1.36-blkid-cache.patch
Comment 5 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-03-22 13:38:50 UTC
I'd think it would be better to do it the other way around, eg. explictly check for GLIBC before using  __secure_getenv. This ensures it can compile on any other libc as opposed to just uclibc.
Comment 6 Thierry Carrez (RETIRED) gentoo-dev 2005-03-22 13:55:48 UTC
We should wait for upstream a little before they chose a final patch
Comment 7 solar (RETIRED) gentoo-dev 2005-03-22 14:12:33 UTC
agriffis put the following proposed solution for this. tested on uClibc and it compiles fine after running autoconf.
http://dev.gentoo.org/~agriffis/misc/e2fsprogs-1.36-blkid-cache.patch
I mailed <tytso@mit.edu> about it, awaiting reply.
Comment 8 SpanKY gentoo-dev 2005-03-22 15:46:07 UTC
1.37 is now in portage w/out any patch here ... i'd prefer upstream handle this which is what Nedd is pursuing

is e2fsprogs-1.35 affected or is it just 1.36 ?  if it's just 1.36, then ia64 is the only one who had that version stable [it was marked last nite ...]
Comment 9 solar (RETIRED) gentoo-dev 2005-03-22 16:37:56 UTC
I'm pretty sure it's 1.36 only. 
Comment 10 Thierry Carrez (RETIRED) gentoo-dev 2005-03-23 00:41:20 UTC
I know upstream was considering pushing some autoconf stuff to enable/disable use of __secure_getenv. Maybe better to wait for their final choice.
Comment 11 solar (RETIRED) gentoo-dev 2005-03-23 06:40:07 UTC
Anybody know the attack vector here? Like nothing in e2fsprogs is suid afaik.
Comment 12 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2005-03-23 07:04:56 UTC
solar: re: attack vector
I think /bin/mount might be an attack vector.
it's suid, and uses the function in question (blkid_get_cache).
it's got the blkid stuff so you can do 'mount LABEL=foo /bar'.
Comment 13 Thierry Carrez (RETIRED) gentoo-dev 2005-03-30 07:15:42 UTC
Keeping the bug open until upstream final resolution, but won't generate a GLSA as affected versions are unsupported.
Comment 14 Thierry Carrez (RETIRED) gentoo-dev 2005-04-21 01:17:34 UTC
Contacted upstream to see what they plan to do exactly.
Comment 15 Thierry Carrez (RETIRED) gentoo-dev 2005-05-15 08:13:35 UTC
A TEST version 1.38-WIP-0509 has been released... No answer from upstream btw.
Comment 16 Thierry Carrez (RETIRED) gentoo-dev 2005-06-10 06:54:46 UTC
Given that I had no answer from upstream on this, I tend to consider 1.37 is
probably the final upstream fix for that.

So should we consider this one fixed ?
Comment 17 SpanKY gentoo-dev 2005-06-10 18:18:34 UTC
works for me

ia64 is now stable in 1.37-r1 since ia64 is the only arch that had 1.36 stable
Comment 18 Thierry Carrez (RETIRED) gentoo-dev 2005-06-11 01:18:18 UTC
Closing as SOMEWHATFIXED. Please reopen if you have a better idea.