mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Solar Designer <solar@openwall.com>
To: musl@lists.openwall.com
Cc: Timo Teras <timo.teras@iki.fi>
Subject: Re: [PATCH] crypt_blowfish: allow short salt strings
Date: Sun, 27 Mar 2016 05:11:21 +0300	[thread overview]
Message-ID: <20160327021121.GA28942@openwall.com> (raw)
In-Reply-To: <1458907955-8698-1-git-send-email-timo.teras@iki.fi>

Hi Timo,

On Fri, Mar 25, 2016 at 02:12:35PM +0200, Timo Ter??s wrote:
> assume the remainder of the salt to be zero bits.
> ---
>  src/crypt/crypt_blowfish.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> Any comments if this makes sense?

Sort of, but we shouldn't do it.

crypt_blowfish is deliberately strict, and recent versions of it (after
the inclusion in musl, though) were cross-tested against OpenBSD's
original implementation resulting in the latter becoming stricter as
well, including on wrong inputs like this.  Prior to that cross-testing,
IIRC it was possible for OpenBSD's implementation to leak uninitialized
stack space on too-short salts like this.  This confirms that too-short
salts were never meant to be supported.  OpenBSD is upstream for bcrypt.

> There seems to be some test suites that even verify that short
> salt strings should succeed.
> 
> See: http://bugs.alpinelinux.org/issues/5141

This looks like a script testing PHP's behavior.  I vaguely recall PHP
relaxing the PHP-embedded crypt_blowfish code like this.  I think they
shouldn't have.  Especially they shouldn't have done that when at the
same time (apparently) continuing to detect and prefer the underlying
system's bcrypt support whenever that is available.

The behavior you're observing on a system with glibc is most likely
actually that of PHP's embedded copy of crypt_blowfish, since upstream
glibc lacks bcrypt support (or has this changed?)  Only some Linux
distros with glibc have bcrypt support patched into their glibc.

There is one maybe-bug seen in your test results: the "*" return on
error.  Normally, it would be "*0" or "*1" for crypt_blowfish, and it
would never match the salt input.  Rich, did musl retain this behavior?
Where does the bare "*" come from?  The concern here is that a "*" might
also be returned when crypt() is called with "*" for the salt input.
Then its output would match what may be a stored hash placeholder, where
"*" means locked account or an error having occurred when the password
was set.  We must deny access in such cases, but returning "*" on all
errors would grant access.  This could be a musl or PHP security bug, if
it's indeed as bad as it appears from that test.

Alexander


  reply	other threads:[~2016-03-27  2:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-25 12:12 Timo Teräs
2016-03-27  2:11 ` Solar Designer [this message]
2016-03-27  2:54   ` Solar Designer
2016-03-27 15:22     ` Solar Designer
2016-03-27  3:30   ` Solar Designer
2016-03-27 13:26     ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160327021121.GA28942@openwall.com \
    --to=solar@openwall.com \
    --cc=musl@lists.openwall.com \
    --cc=timo.teras@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).