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

Possible regression of "BSD wraparound" bug? #80

Closed
ivan-c opened this issue Jun 29, 2016 · 4 comments · Fixed by #81
Closed

Possible regression of "BSD wraparound" bug? #80

ivan-c opened this issue Jun 29, 2016 · 4 comments · Fixed by #81

Comments

@ivan-c
Copy link

ivan-c commented Jun 29, 2016

passlib implements a specific check against the "BSD wraparound" bug that now appears to be failing with bcrypt 3.0

Although the included source from libcrypt appears to have been updated since the bug was fixed (OpenBSD 5.5, according to passlib) I'm not familiar enough with the code to be able to tell if this is a genuine regression or not

@charmander
Copy link

The check uses a $2a$ hash where the behaviour is maintained for compatibility:

switch ((minor = salt[1])) {
case 'a':
    key_len = (u_int8_t)(strlen(key) + 1);
    break;
case 'b':
    /* strlen() returns a size_t, but the function calls
     * below result in implicit casts to a narrower integer
     * type, so cap key_len at the actual maximum supported
     * length here to avoid integer wraparound */
    key_len = strlen(key);
    if (key_len > 72)
        key_len = 72;
    key_len++; /* include the NUL */
    break;
⋮

@dstufft
Copy link
Member

dstufft commented Jun 29, 2016

I think maintaining compatibility for this is kind of bonkers, but in any case, prior to 3.0 we had the fix even for $2a in this library, so we should restore said fix.

@reaperhulk
Copy link
Member

reaperhulk commented Jun 29, 2016

@dstufft do you have an opinion on how we should fix this to have it behave the same as bcrypt 2.0.0? Could we take all input passwords and do password = password[:72]?

@dstufft
Copy link
Member

dstufft commented Jun 29, 2016

Truncating to 72 seems reasonable, since that's all the C code is going to do anyways in the correct case.

reaperhulk added a commit to reaperhulk/bcrypt that referenced this issue Jun 29, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants