Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest getrandom interface which is available on newer OSes. #1373

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

loganaden
Copy link

No description provided.

@loganaden loganaden requested a review from ekr as a code owner February 10, 2025 07:14
as /dev/urandom, which should be used absent other (e.g., performance) concerns.
as /dev/urandom, which should be used absent other (e.g., performance) concerns. On
newer Operating Systems, the getrandom interface SHOULD be used as
it can be used in sandboxing environments.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an objection per se, but I dunno if we want to get into a whole digression in the spec about different APIs to access the PRNG. E.g. getrandom is Linux-specific, then there's getentropy, and then there's the mess about which versions of Linux have which early boot behavior.

Makes me wonder if we should say anything at all here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, while the intention is good, I think it's too Linux specific

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do want to keep the guidance on "use the OS CSPRNG rather than rolling your own" (ISTR that I added it in the first place but apparently don't have a checkout on this device to look), and giving one example seems probably reasonable but maybe not necessary. Going into the details of multiple different interfaces feels a bit overspecific for the protocol spec, though maybe in an "implementation notes" section it is still ok?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, +1 to keeping the mention of the OS. Sorry, "say anything at all" wasn't right. I was thinking just not saying anything about the specific API, but wrote something broader.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidben @kaduk would something like "On newer operating systems, other interfaces, which do not require opening a file descriptor and can be used in in sandboxing environment, SHOULD be used" ?

Copy link
Contributor

@davidben davidben Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the TLS spec should opine about something as implementation-specific as which Linux-specific APIs are or aren't friendly for sandboxing. Definitely not at the level of a SHOULD.

I mean, depending on the sandboxing strategy and the TLS stack's structure, /dev/urandom might even be better than getrandom for a sandbox. Imagine a syscall-filtering sandbox that hasn't been updated for getrandom, paired with a capabilities-heavy TLS stack that actually happily takes an externally-supplied /dev/urandom file descriptor.

(Though, yes, getrandom is probably generally more sandboxing-friendly than /dev/urandom in most cases. Certainly we prefer it for Chrome's sandbox. I wouldn't expect most TLS libraries to happily take an externally-supplied fd in lieu of /dev/urandom. But it's a plausible enough design to disqualify this guidance IMO. And then you've got Windows, where the APIs and sandboxing considerations are completely different.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, practically speaking, the TLS library is probably calling into its cryptography library's general-purpose PRNG interface, so it's not like it's going to do anything special anyway.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something like this be better @davidben @kaduk : A performant and appropriately-secure CSPRNG is provided by most operating systems or can be sourced from a cryptographic library.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Comment on lines 5215 to +5218
In most cases, the operating system provides an appropriate facility such
as /dev/urandom, which should be used absent other (e.g., performance) concerns.
as /dev/urandom, which should be used absent other (e.g., performance) concerns. On
newer Operating Systems, the getrandom interface SHOULD be used as
it can be used in sandboxing environments.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't suggest this, but here's what I'd say:

A performant and appropriately-secure CSPRNG is provided
by most operating systems or can be sourced from a cryptographic library.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it.

@@ -5223,7 +5226,7 @@ TLS uses random values (1) in public protocol fields such as the
public Random values in the ClientHello and ServerHello and (2) to
generate keying material. With a properly functioning CSPRNG, this
does not present a security problem, as it is not feasible to determine
the CSPRNG state from its output. However, with a broken CSPRNG, it
the CSPRNG state from its output. However, with a broken or compromised CSPRNG, it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it true that compromised \subsetof broken ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broken seems to be sufficient. This sentence is a counterpoint to properly functioning CSPRNG in the previous sentence.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. Will remove this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants