Issue 8196 - PRNG from ITS#7027 (shuffling DNS SRV records) is poorly seeded
Summary: PRNG from ITS#7027 (shuffling DNS SRV records) is poorly seeded
Status: RESOLVED TEST
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: 2.4.40
Hardware: All All
: --- enhancement
Target Milestone: 2.7.0
Assignee: Ondřej Kuzník
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-12 09:11 UTC by sergio.gelato@astro.su.se
Modified: 2023-10-23 17:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description sergio.gelato@astro.su.se 2015-07-12 09:11:33 UTC
Full_Name: Sergio Gelato
Version: 2.4.40
OS: Linux
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (85.225.123.131)


As part of ITS#7027, a simple PRNG was added to libraries/libldap/dnssrv.c in
order to implement shuffling of SRV RRs as per RFC2782.

I see two shortcomings with the way this generator is being seeded.

(1) The seed is a very slowly varying function of time: (float)time(NULL) /
(2**32-1). The mantissa of an IEEE754 float has 24 bits, so one only gets a new
seed every 2**7 seconds with the current seeding method.

(2) At any given time, all clients areikikely to use the same seed and therefore
pick the same SRV record. This means the load on individual servers will
fluctuate a lot more than if the clients picked records in an uncorrelated
fashion.

To fix (1) I think we need to hash the seed so that it is much more sensitive to
the least significant bit of the current time value. (2) can be addressed by
mixing in some value that varies from client to client; maybe the 16-bit DNS
query ID is most readily available (as the first two bytes of the reply buffer;
I hope all implementations of res_query() return it). Come to think of it,
shifting the query ID up by 15 bits and XORing with the current time might be
good enough.
Comment 1 Quanah Gibson-Mount 2017-04-03 16:47:27 UTC
moved from Incoming to Software Bugs
Comment 2 Quanah Gibson-Mount 2023-10-23 17:06:03 UTC
commit 1220282dd5f941829e999d612eeb226e532b55d7
Author: Ondřej Kuzník <ondra@mistotebe.net>
Date:   Fri Sep 16 14:49:11 2022 +0100

    ITS#8196/ITS#9714 Switch to xorshift