Hi, I’ve used SessionStorage for storing session o...
# ktor
d
Hi, I’ve used SessionStorage for storing session on Redis. And I find a point that makes me worried about security. The point is about “the security for birthday attack”. I’m not good at security, so almost certainly my anxiety is wrong. 🙏 I’d ask someone who are familier with it.
Copy code
As I said, I use SessionStorage.
<https://ktor.io/servers/features/sessions/storages.html>

And I find the responded cookie value is in below format.
`78a095a61d3e58a2`

This value is generated by `generateNonce` function.
<https://github.com/ktorio/ktor/blob/master/ktor-server/ktor-server-core/jvm/src/io/ktor/sessions/SessionsBuilder.kt#L271>
(The concrete implementation is in Nonce.kt <https://github.com/ktorio/ktor/blob/master/ktor-utils/jvm/src/io/ktor/util/Nonce.kt> )

I understand the cookie value is hard to guess because the SecureRandom is used, but I'm worried about collision.

The cookie value is 64bit. (`78a095a61d3e58a2`)
So, the expected number of cookie values that can be generated before getting a collision is 2^(64/2) = 4,294,967,296.

> The birthday problem in this more generic sense applies to hash functions: the expected number of N-bit hashes that can be generated before getting a collision is not 2N, but rather only 2​N⁄2.
<https://en.wikipedia.org/wiki/Birthday_problem>

I wonder if 4,294,967,296 is enough to protect birthday attack.
Does anyone know about this?
s
I would say its on the edge of reasonable. I dont even think we would reach that as a top 1000 site
But its silly to even have this discussion by saving 64 bits over choosing ie. 128. I chose 128 bits in my own session impl.
but maybe there is a technical reason
👀 1