Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

okta-hosted-login: nonce is a global but used for multiple sessions #88

Open
jimsnab opened this issue Jan 4, 2022 · 5 comments
Open

Comments

@jimsnab
Copy link

jimsnab commented Jan 4, 2022

The code declares nonce as a global, but assigns this global in the login handler (per user) and reads it in verifyToken. This doesn't work if two separate users are logging in at the same time.

@jimsnab jimsnab changed the title nonce is a global but used for multiple sessions okta-hosted-login: nonce is a global but used for multiple sessions Jan 4, 2022
@monde
Copy link
Collaborator

monde commented Jan 6, 2022

Thanks @jimsnab . We're in the process of updating our samples. I correct the nonce usage when I'm done with the other updates.

@jimsnab
Copy link
Author

jimsnab commented Jan 7, 2022

@monde excellent. As of now I don't see how nonce prevents man-in-the-middle replay, because the server that initiates authentication doesn't seem to have a solid way of keeping track of which client is associated with the auth code callback.

What I've done is save the generated nonce on the server for up to 1 minute, and upon receiving the auth code, try each saved nonce when validating the jwt. At least this way the attack window is only 1 minute, and the server-generated nonce can be destroyed after the first successful jwt validation.

My approach is janky, and I'm looking forward to okta guidance on the right way to handle nonce.

@askreet
Copy link

askreet commented Oct 29, 2023

@monde Any updates here. I'm using this code as a basis and I've immediately noticed the same, both the state and the nonce are stored in globals and assume a single session on a single process. For any service deployed in a highly available fashion, this will fail.

@monde
Copy link
Collaborator

monde commented Oct 30, 2023

@askreet we're not currently putting any development cycles into okta/samples-golang . Please open a https://support.okta.com/ ticket to get immediate help from a support engineer.

cc: @jefftaylor-okta

@zymsys
Copy link

zymsys commented Nov 6, 2023

I just submitted the above PR to address this issue. I realize it isn't likely to be merged, but maybe it will help others facing the same problem.

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

No branches or pull requests

4 participants