Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20261120155812.GK5716@brightrain.aerifal.cx>
Date: Fri, 20 Nov 2026 10:58:12 -0500
From: Rich Felker <dalias@...c.org>
To: Solar Designer <solar@...nwall.com>
Cc: Lukas Tribus <lukas@...i.eu>, musl@...ts.openwall.com
Subject: Re: crypt: unsupported hash behavior

On Fri, Nov 20, 2026 at 04:22:07PM +0100, Solar Designer wrote:
> On Fri, Nov 20, 2026 at 09:41:46AM -0500, Rich Felker wrote:
> > On Fri, Nov 20, 2026 at 01:38:25PM +0100, Solar Designer wrote:
> > > On Fri, Nov 20, 2026 at 07:23:14AM -0500, Rich Felker wrote:
> > > > On Fri, Nov 20, 2026 at 10:53:00AM +0100, Solar Designer wrote:
> > > > > Not addressing the issue of leaving the hash in memory yet, but I assume
> > > > > that's intentional not to address in this same patch?
> > > > 
> > > > Yeah I wasn't sure what to best do with that. I thought of having the
> > > > loop that computes the sum also xor the setting string onto the
> > > > output, which would be a great way to keep a dependency and avoid
> > > > short-circuiting the loop, but that leaks setting (good hash) on
> > > > failure which is even worse. I guess I could just make the loop
> > > > overwrite output as it runs -- that might be worthwhile.
> > > 
> > > I had thought of this too, but the problem is we don't know we need to
> > > overwrite output until the loop ends.  Also the early exit on
> > > strlen(_setting) != 13 must not skip the zeroization.
> > 
> > Oh, yes. In that case, I think we should probably just leave this
> > aspect alone for now.
> 
> OK, I agree.
> 
> > Leaving the hash *of the caller submitted
> > password* in the caller's buffer is not really a big deal anyway.
> 
> It's in the caller's buffer only with crypt_r(), otherwise with normal
> crypt() it's our output buffer.
> 
> > As a separate change later, I do have an idea for this: when the crypt
> > core produces a failure, we could have the subsequent self-test write
> > to the caller's output buffer instead of a test_buf. This could be
> > applied to all of the crypt backends, though I'm not sure if any have
> > other data worth clobbering.
> 
> Like I wrote in a previous message in this thread:
> 
> One way to deal with this could be to use the output pointer in place of
> test_buf in the self-test call if retval is NULL by that point:
> 
> -	p = _crypt_extended_r_uut(test_key, test_setting, test_buf);
> +       p = _crypt_extended_r_uut(test_key, test_setting, retval ? test_buf : output);
> 
> but that's dangerous in a different way: the passed struct crypt_data
> would then get a fixed hash into it corresponding to our known test
> password.  So if any caller to crypt_r() uses that, or any caller to
> crypt() reuses a previous call's returned pointer (of course either
> behavior would be a bug), they may be vulnerable.

Oh, yes, I remember now. It's really looking like the best thing is
not to do anything special with it, and just leave it as this patch
leaves it.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.