oss-sec mailing list archives

CVE request: automake: insecure use of /tmp in install-sh


From: Vasyl Kaigorodov <vkaigoro () redhat com>
Date: Fri, 12 Sep 2014 14:29:40 +0200

Hello,

It was discovered [1] that there's an issue in how automake handles
temp directories.

When the destination directory does not exist, install-sh checks if 
"mkdir -p" works, but it does so in an insecure way. Here are the 
relevant parts of the code:

mkdirprog=${MKDIRPROG-mkdir}
# ...
        tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
        trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit
$ret' 0

        if (umask $mkdir_umask &&
        exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
        then
# ...
          rmdir "$tmpdir/d" "$tmpdir"
        else
# ...

In some shells (such as dash) $RANDOM is not set, so $tmpdir is easily 
predictable. Moreover, "mkdir -p" follows symlinks to existing 
directories. Local attacker can exploit this to create or remove empty 
directories named "d". (But on modern Linux systems this is mitigated
by the protected_symlinks feature.)

References:
[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760455
[2]: https://bugzilla.redhat.com/show_bug.cgi?id=1140725
[3]: https://bugs.gentoo.org/show_bug.cgi?id=522638

Can a CVE ID be assigned to this please?

Thanks.
-- 
Vasyl Kaigorodov | Red Hat Product Security
PGP:  0xABB6E828 A7E0 87FF 5AB5 48EB 47D0 2868 217B F9FC ABB6 E828

Attachment: _bin
Description:


Current thread: