oss-sec mailing list archives

Re: libxslt math.random issue


From: Hanno Böck <hanno () hboeck de>
Date: Thu, 6 Apr 2017 10:32:45 +0200

Hi,

On Thu, 6 Apr 2017 07:44:00 +0200
Marcus Meissner <meissner () suse de> wrote:

CVE-2015-9019 has been assigned to use of libexslt (in libxslt) usage
of "math.random" without initializing the randomseed.

https://bugzilla.gnome.org/show_bug.cgi?id=758400
https://bugzilla.suse.com/show_bug.cgi?id=934119

I have some questions and comments:

1. What's the use of the random number and what's the security impact
if it's not random? That's not explained
In case of the bugreport.
In case a cryptographically secure random number is required then using
rand()/srand() is a bad idea anyway.
(Unfortunately there's no secure random in the standard libc, but at
least glibc now has getrandom.).

2. This part of the patch looks a bit strange:

+       seed = time(NULL); /* just in case /dev/urandom is not there */
+       if (fd == -1) {
+               read (fd, &seed, sizeof(seed));
+               close (fd);
+       }

You're calling time() unconditionally, although it's kinda just a
fallback. Why not
+       if (fd == -1) {
+               read (fd, &seed, sizeof(seed));
+               close (fd);
+       } else {
+               seed = time(NULL);
+       }
?

(obviously using time is not a secure way to do random numbers, if
secure numbers are required cross-plattform you need to do this
otherwise anyway)


-- 
Hanno Böck
https://hboeck.de/

mail/jabber: hanno () hboeck de
GPG: FE73757FA60E4E21B937579FA5880072BBB51E42


Current thread: