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

Timing attack vulnerability #7

Open
moparisthebest opened this issue Mar 28, 2017 · 0 comments
Open

Timing attack vulnerability #7

moparisthebest opened this issue Mar 28, 2017 · 0 comments

Comments

@moparisthebest
Copy link

This should not use Arrays.equals:
https://github.com/Robbert1/boot-stateless-auth/blob/master/src/main/java/com/jdriven/stateless/security/TokenHandler.java#L41

Instead it should use a constant time equality checking method like

public static boolean isEqual(byte[] a, byte[] b) {
    if (a.length != b.length) {
        return false;
    }

    int result = 0;
    for (int i = 0; i < a.length; i++) {
      result |= a[i] ^ b[i];
    }
    return result == 0;
}

Which is from https://codahale.com/a-lesson-in-timing-attacks/ which gives a good explanation of this exact vulnerability.

This seems like a popular article and code, I'd hate to see people using it in production in it's current vulnerable state, can you fix the article and code?

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

No branches or pull requests

1 participant