Live data from Hacker News

Ruby Bug: SecureRandom should try /dev/urandom first

bugs.ruby-lang.org

101–110 of 138 posts

Re: Ruby Bug: SecureRandom should try /dev/urandom first

#101
post #86
post #11

Earlier quoted context omitted.

It does not depend on your use case. The answer, in all cases, is just to use /dev/urandom.

Are there not cases where blocking if there is insufficient entropy is the correct thing to do? Particularly if we're talking about important random numbers like long-lived private keys.

No, there are not [1].

[1]: http://sockpuppet.org/blog/2014/02/25/safely-generate-random...

Re: Ruby Bug: SecureRandom should try /dev/urandom first

#102
post #39

To make this discussion really useful: what's the easiest way for a Ruby application to make SecureRandom use /dev/urandom, without waiting for Ruby-core to be convinced?

require "securerandom" module SecureRandom F = File.open("/dev/urandom") def self.random_bytes(n = nil) F.read(n || 16) end end

Why not just make the argument default to 16? Is something non-obvious going on?

Re: Ruby Bug: SecureRandom should try /dev/urandom first

#103

Earlier quoted context omitted.

require "securerandom" module SecureRandom F = File.open("/dev/urandom") def self.random_bytes(n = nil) F.read(n || 16) end end

Why not just make the argument default to 16? Is something non-obvious going on?

The caller may pass nil explicitly.

Re: Ruby Bug: SecureRandom should try /dev/urandom first

#104
post #92

Earlier quoted context omitted.

Cryptographers really are part of the problem. Do you ever Read the discussions in the metzdowd/crypto list? Nobody agrees on anything.

The metzdowd list is a running joke among practitioners. The direct answer to your question is "no."

I stopped reading these 'cypherpunk'-epilog lists a few years back. I'm still subscribed because of cross-postings. The amount of tinfoil-hattery is just unsustainable. And there's barely any interesting information for people working on real cryptography-, systems or engineering.

Re: Ruby Bug: SecureRandom should try /dev/urandom first

#105
post #86

Earlier quoted context omitted.

Are there not cases where blocking if there is insufficient entropy is the correct thing to do? Particularly if we're talking about important random numbers like long-lived private keys.

No, there are not [1]. [1]: http://sockpuppet.org/blog/2014/02/25/safely-generate-random...

It must be possible for a computer to simply not have an adequate supply of randomness though, no? Sure, urandom will use hardware sources of randomness if they're available - but what if they're not?

Re: Ruby Bug: SecureRandom should try /dev/urandom first

#106
post #77

Earlier quoted context omitted.

The authoritative source in Linux is the code and always has been.

Code is useless if no one knows how to use it properly and it's not communicated clearly. Users certainly can't be expected to read every line of code. That's like shipping a car with no user manuals and saying "take the engine apart and see how it works." Arrogance. Clearly document system behavior or code is essentially useless.

Then I have a little quiz for you:

According to this documentation:

http://ruby-doc.org/core-2.1.2/Float.html#method-i-round

How do you explain?

2.1.2 :011 > 15.round(-1) => 20

Re: Ruby Bug: SecureRandom should try /dev/urandom first

#107
post #65

This is sad and embarrassing for every involved party. The people leaving rude, entitled, hyperbolic comments in the thread, the Ruby developers who refuse to look into the best practice suggested by experts in the field, and the man page maintainer who refuses to update the man page in accordance with similar information.

Agreed that tensions are running high. But I think the ruby devs are in the right here. They are just following the man page. What else is the authoritarian source? How is one supposed to know who wrote those blog posts? Just because it is linuxexpert.com does not mean they are linux experts. It's funny, if people changed it randomly following blogs then people will claim this is some NSA conspiracy :-) How does one…

Agreed. The problem is the man page. Suggesting that one should read the source code instead of the man page is ridiculous. Might as well write your own kernel while you're at it if that's the case.

Re: Ruby Bug: SecureRandom should try /dev/urandom first

#108
post #66

I really don't like the sentiment of "We shouldn't change it unless the man page says we can". That's exactly the kind of senseless bureaucracy that the open source community should be avoiding.

Huh? So you want them to make code changes which is against the man page recommendation? Why have man pages at all then? Do you expect ruby developers to dig into kernel source code and more importantly actually understand what is in there? If you think they should take the word of 'experts', how does one qualify as an expert? How do you verify that the expert is the one who wrote the blog post or mail etc etc. The p…

> Do you expect ruby developers to dig into kernel source code and more importantly actually understand what is in there?

Yes. Anyone maintaining and distributing the security related code of a language runtime should understand as much as humanly possible about what is actually going on from the application level all the way down to the hardware.

Re: Ruby Bug: SecureRandom should try /dev/urandom first

#109
post #65

Earlier quoted context omitted.

Agreed that tensions are running high. But I think the ruby devs are in the right here. They are just following the man page. What else is the authoritarian source? How is one supposed to know who wrote those blog posts? Just because it is linuxexpert.com does not mean they are linux experts. It's funny, if people changed it randomly following blogs then people will claim this is some NSA conspiracy :-) How does one…

> They are just following the man page. I think Ruby devs' position is more than this. By keeping the faulty man page, Linux maintainers are implicitly communicating that they intended `/dev/urandom` to be a limited and less recommended way of doing things. The intention is important: even though `/dev/urandom` is actually better in the current kernel it may not in the future. It is not the only answer, as other lang…

Exactly what, do you imagine, Linux could do to make urandom less secure? I'm sorry, but the word for that concern is "nonsensical". Linus Torvalds has world-shattering conniption fits when developers make changes that hurt performance. Can you imagine breaking every one of the many security applications --- for instance, every Go program ever written --- that depend on urandom?

No, that is not a legitimate concern.

Re: Ruby Bug: SecureRandom should try /dev/urandom first

#110
post #85
post #48

Earlier quoted context omitted.

> We don't expect person writing a Ruby binding for sqlite to know the theory behind database indexes and who are the acknowledged experts in that field. We don't? More to the point, do we expect them to close a bug related to those things without educating themselves on the subject enough to make a rational decision on it?

I think it would be entirely reasonable for the person maintaining a Ruby binding for sqlite to follow the sqlite documentation and close any bugs telling them to go against that documentation, yes.

It goes against the Linux kernel documentation, yes. As has been pointed out to them, it doesn't go against the documentation on OS X or any of the BSDs. But they engage in the same behavior on those systems.
Post reply on HN