I need validation / feedback please with the implementation of a web based client-server application that I am building.

I need to make sure that a client's cookies can't be hijacked and therefore I have introduced a nonce.

So with each request from the client a {nonce, Hash(nonce, shared-secret)} is provided to the server.

I would like to not manage a table of previously used nonces on the server. Therefore I've considered using an incrementing only nonce. So that with each request I increment the nonce so that it only grows to a larger number. Thus, the server just needs to keep track of the last used nonce.

My first question is if there is a security problem with this approach? It makes the nonce somewhat predictable (in the extreme case increasing the nonce by 1 on each request)

My second question is which Hash() function would be good to use. I am looking for something quick. I guess MD5 or SHA-256 might be an obvious choice. But is something like a CRC32C a possibility or is it too weak given it's not a hash?

Thank you.

  • You should take a look at JWT. It's a mature technology with lots of available documentation, and ready to use libraries. Don't reinvent something sensitive if security experts already invented it for you.
    – ThoriumBR
    Jul 29, 2021 at 12:08
  • I've looked JWT over. I have two concerns. JWTs are likely to require too many resources for the scale of system i am designing for. Secondly, maybe i read it wrong, but it appears to me the JWT can still be compromised (albeit for a shorter period of time). With the shared secret nonce above it should hopefully be impossible to hijack the tokens. Jul 30, 2021 at 7:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.