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

GenerateRandomKey: do not swallow errors #85

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

Conversation

majewsky
Copy link

@majewsky majewsky commented Nov 8, 2023

This is a bugfix; make verify and make test are passing.

The requirement to check for nil returns from GenerateRandomKey is so unexpected that even other Gorilla libraries get it wrong:

https://github.com/gorilla/sessions/blob/3eed1c4ffcde6f23b6f88068c63c1ef6190df331/store.go#L225

Since a malfunction of the system random number generator is pretty unrecoverable for most security-sensitive applications, I consider it fine to use a panic here. #84 suggests to fix this by changing the interface, but most callers will have no better option than to just die anyway. If callers need a more specific behavior, they can implement these three lines of code themselves with application-specific error handling.

The requirement to check for nil returns is so unexpected that even
other Gorilla libraries get it wrong:

<https://github.com/gorilla/sessions/blob/3eed1c4ffcde6f23b6f88068c63c1ef6190df331/store.go#L225>

Since a malfunction of the system random number generator is pretty
unrecoverable for most security-sensitive applications, I consider it
fine to use a panic here. Most callers will have no better option than
to just die anyway. If callers need a more specific behavior, they can
implement these three lines of code themselves with application-specific
error handling.
@AlexVulaj
Copy link
Member

I'm okay with this change, @coreydaley can you give a second look please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

2 participants