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

Random not secure, switch to SecureRandom #205

Open
Gax-c opened this issue May 14, 2024 · 0 comments
Open

Random not secure, switch to SecureRandom #205

Gax-c opened this issue May 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Gax-c
Copy link

Gax-c commented May 14, 2024

Hi, I am new to JustAuth, and when I was browsing the code I found in the file GlobalAuthUtils.java, Random is used to generate the nonce here.

    public static String generateNonce(int len) {
        String s = "0123456789QWERTYUIOPLKJHGFDSAZXCVBNMqwertyuioplkjhgfdsazxcvbnm";
        Random rng = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < len; i++) {
            int index = rng.nextInt(62);
            sb.append(s, index, index + 1);
        }
        return sb.toString();
    }

However, it's not secure enough, so switching to SecureRandom can be a better choice.

@Gax-c Gax-c added the bug Something isn't working label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant