ranger-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jiayi Liu <liujiayi...@gmail.com>
Subject Re: Review Request 71998: RANGER-2700: Use SecureRandom.getInstance(NativePRNGNonBlocking) to get random string
Date Mon, 20 Jan 2020 11:20:50 GMT

This is an automatically generated e-mail. To reply, visit:

(Updated 一月 20, 2020, 11:20 a.m.)

Review request for ranger, Ankita Sinha, bhavik patel, Gautam Borad, Abhay Kulkarni, Madhan
Neethiraj, Mehul Parikh, Nikhil P, Nitin Galave, Ramesh Mani, Sailaja Polavarapu, and Velmurugan

Bugs: RANGER-2700

Repository: ranger


In Ranger-2.0.0, the request that creating new service often stuck on generateBase64EncodedIV()
in PasswordUtils.java. It uses SecureRandom.getInstanceStrong() to get the random string.
We can find a lot of information showing that this function often blocks and is very slow.
SecureRandom.getInstanceStrong() uses /dev/random, and /dev/random blocks the thread if there
isn't enough randomness available, but /dev/urandom will never block.

SecureRandom.getInstanceStrong() is equivalent to SecureRandom.getInstance("NativePRNGBlocking"),
so we can use /dev/urandom by replacing SecureRandom.getInstanceStrong().nextBytes(iv) with
SecureRandom.getInstance("NativePRNGNonBlocking").nextBytes(iv) which will not be blocked,
or we can use new SecureRandom().nextBytes(iv). /dev/random and /dev/urandom use the same
pool of randomness under the hood, and they are equally secure.


  agents-common/src/main/java/org/apache/ranger/plugin/util/PasswordUtils.java c08f55d6e 

Diff: https://reviews.apache.org/r/71998/diff/1/

Testing (updated)

1. Passes all unit tests
2. Tested Ranger service creation, and there is no blocking situation like before


Jiayi Liu

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message