securecookie icon indicating copy to clipboard operation
securecookie copied to clipboard

GenerateRandomKey: do not swallow errors

Open majewsky opened this issue 2 years ago • 1 comments

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.

majewsky avatar Nov 08 '23 15:11 majewsky

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

AlexVulaj avatar Nov 13 '23 04:11 AlexVulaj