You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Greg Stein <gs...@gmail.com> on 2012/03/26 19:28:38 UTC

Re: [Issue 4145] Master passphrase and encrypted credentials cache

Oh... just saw this. I already updated the wiki page with some stuff
based on another project that I'm working on. The design points in
there were provided by a security expert friend of mine. More below:

On Mon, Mar 26, 2012 at 11:45, Greg Hudson <gh...@mit.edu> wrote:
>...
> Unfortunately, there's more complexity in an encrypted password store
> than you probably anticipated, and it's definitely possible to lose
> some or most of your intended security properties if you get it wrong.
>
> The choice of best cipher algorithm today is very simple (AES,
> although you'll have to pick the key size from 128/196/256 bits), but

AES-256 in CBC mode was my buddy's suggestion.

> you do need to decide whether you want to be cipher-agile.  Basically,
> if AES becomes a weak choice down the road (and it probably will,
> though it could be decades), is it better to be able to swap out the
> algorithm inside the password storage system, or better to just plan
> to swap out the system entirely for a redesigned one?  Either position
> is defensible.

I'd suggest going with a single choice and leave it at that. It will
be good into the future, for as long as Subversion has existed in the
past. Security-conscious people can immediately switch once we provide
a new subsystem in ten years. Muggles will just naturally migrate as
the update their svn installation.

Keeping the implementation simple at this stage will be important. A
big chunk of Mike's work is to untangle the growth that has occurred
in the authn subsystem over the past ten years. The simplicity will
also help in a security review.

> You'll need to pick a function to map a passphrase to a crypto key.
> If you do a bad job, it will become easier to brute-force search for
> keys because your key distribution won't be even.  To ensure even
> distribution, you typically need to use a hash function, which is an
> added dependency.  String-to-key functions are also often deliberately
> slow, to make offline dictionary attacks harder.  PBKDF2 (RFC 2898) is
> a reasonable choice here, and is implemented in some crypto libraries.

Agreed on PBKDF2. John mentioned the same thing, though I didn't need
it for my particular problem (I have no master passphrase; just needed
to securely store a bunch of passwords).

> You'll need to pick an appropriate cipher mode.  If you simply use ECB
> (where you chunk the plaintext up into blocks and encrypt each block
> with the key), it will become easy to tell which passwords, or parts
> of passwords, are the same as which others.  Maybe not a critical
> flaw, but certainly an avoidable one.  If you use CTR (where you
> encrypt counter values with the key and XOR the result with the
> password), you'll need to make sure that counter values are never
> reused, or it will become easy to recover passwords with the key.  CBC
> with a random initialization vector is also an option.

Per above, CBC mode was recommended. We can grab 128 bits of
cryptorandom data for the IV.

> If you don't use CTR mode, you'll need to pick a reversible padding
> function for the plaintext so that it matches a multiple of the
> cipher's block size.  This is pretty simple.

In my wiki update, I mentioned 32 bits of random prefix (makes
dictionary attacks even harder), and pad with NUL characters. AES uses
16 byte blocks, and keys of 16/24/32 bytes.

> It's probably wise to look at what another implementation does.  I'm
> not sure what password store implementations have made obvious
> mistakes and which ones haven't; I wish I had a better reference to
> give, but I don't know the state of the art for this particular
> application of crypto as well as others.

This should be quite doable, if we stick to a single, straightforward
design. Much of the pluggable stuff that is in the authn code can
probably be hauled into the "mainline" code now that we have more
experience. Certainly, breaking the link between authn algorithm and
data storage will help tremendously.

Cheers,
-g

Re: AW: [Issue 4145] Master passphrase and encrypted credentials cache

Posted by Greg Stein <gs...@gmail.com>.
On Mar 27, 2012 12:52 PM, "Stefan Sperling" <st...@elego.de> wrote:
>
> On Tue, Mar 27, 2012 at 11:46:50AM -0400, Greg Stein wrote:
> > On Mar 27, 2012 10:10 AM, "Markus Schaber" <m....@3s-software.com>
> > > I hope that expert really is an expert.
> >
> > Yes, he is. John Viega.
>
> Funny how both of your wikipedia entries mention MUD.
>
> Perhaps the upcoming generation of hackers will have first met in WOW :)

That's how we met :-) ... back in 1994. John is the guy that got me into
Python. I was also the very first deployment of Mailman when John wrote it,
and ran it on my servers so John could run the fan mailing list for the
Dave Matthews Band.

Long time, very good friends.

Cheers,
-g

Re: AW: [Issue 4145] Master passphrase and encrypted credentials cache

Posted by Stefan Sperling <st...@elego.de>.
On Tue, Mar 27, 2012 at 11:46:50AM -0400, Greg Stein wrote:
> On Mar 27, 2012 10:10 AM, "Markus Schaber" <m....@3s-software.com>
> > I hope that expert really is an expert.
> 
> Yes, he is. John Viega.

Funny how both of your wikipedia entries mention MUD.

Perhaps the upcoming generation of hackers will have first met in WOW :)

Re: AW: [Issue 4145] Master passphrase and encrypted credentials cache

Posted by Greg Stein <gs...@gmail.com>.
On Mar 27, 2012 10:10 AM, "Markus Schaber" <m....@3s-software.com>
wrote:
>
> Hi, Gregs,
>
> Von: Greg Stein [mailto:gstein@gmail.com]
>
> > On Mon, Mar 26, 2012 at 11:45, Greg Hudson <gh...@mit.edu> wrote:
> > >...
> > > Unfortunately, there's more complexity in an encrypted password store
> > >than you probably anticipated, and it's definitely possible to lose
> > >some or most of your intended security properties if you get it wrong.
> > >
> > > The choice of best cipher algorithm today is very simple (AES,
> > > although you'll have to pick the key size from 128/196/256 bits), but
> >
> > AES-256 in CBC mode was my buddy's suggestion.
>
> I hope that expert really is an expert.

Yes, he is. John Viega. Thanks for not trusting me. :-/

>
> Playing with crypto on your own is never a good idea.

I am well aware, thank you. That is precisely why I talked to John about
the scenario in my personal project. He responded with design info for
svn's scenario, but then tweaked his response a bit when I mentioned I had
no master passphrase. IOW, we already have some expert advice for what svn
is trying to do.

> So we really should have good reasons to do it on our own, and then try
very hard to make sure that we do it "right". :-)

What do you think we're already doing?

>...
> We could use some marker-tag or header naming the algorithm, so upgrades
can be done in a future-proof way, but actually implementing one single
algorithm should be enough.

No need for a tag. It is specified by the design. A tag gives you no extra
data.

> > > If you don't use CTR mode, you'll need to pick a reversible padding
> > > function for the plaintext so that it matches a multiple of the
> > > cipher's block size.  This is pretty simple.
> >
> > In my wiki update, I mentioned 32 bits of random prefix (makes
dictionary
> > attacks even harder), and pad with NUL characters. AES uses
> > 16 byte blocks, and keys of 16/24/32 bytes.
>
> Padding with NUL characters opens a known plaintext window at the end of
the passphrase. Maybe it's better to pad with random characters.

Then you need a length. Either way, I don't care.

>
> Hmm, I remember someone saying it's not easy to get crypto right, right?
:-)

Oh, shut up already. I know that.

-g

AW: [Issue 4145] Master passphrase and encrypted credentials cache

Posted by Markus Schaber <m....@3s-software.com>.
Hi, Gregs,

Von: Greg Stein [mailto:gstein@gmail.com]

> On Mon, Mar 26, 2012 at 11:45, Greg Hudson <gh...@mit.edu> wrote:
> >...
> > Unfortunately, there's more complexity in an encrypted password store
> >than you probably anticipated, and it's definitely possible to lose
> >some or most of your intended security properties if you get it wrong.
> >
> > The choice of best cipher algorithm today is very simple (AES,
> > although you'll have to pick the key size from 128/196/256 bits), but
> 
> AES-256 in CBC mode was my buddy's suggestion.

I hope that expert really is an expert.

Playing with crypto on your own is never a good idea. And choosing the right algorithm is the least important thing to think about when using cryptography. In most cases, using a crypto algorithm directly plainly is the wrong thing to do.

In one of my former jobs, we tried to design our own crypto protocol (some kind of "lightweight" SSL for UDP and SMS), and it was more than one year of tweaking of a group of roughly a dozen bright people, and in addition several semi-public reviews in some crypto discussion groups until we were sure that we'd shaken out most of the problems.

Some nice writeup for that subject I found some months ago:

"If You're Typing The Letters A-E-S Into Your Code, You're Doing It Wrong"
http://chargen.matasano.com/chargen/2009/7/22/if-youre-typing-the-letters-a-e-s-into-your-code-youre-doing.html

So we really should have good reasons to do it on our own, and then try very hard to make sure that we do it "right". :-)

> > you do need to decide whether you want to be cipher-agile.  Basically,
> > if AES becomes a weak choice down the road (and it probably will,
> > though it could be decades), is it better to be able to swap out the
> > algorithm inside the password storage system, or better to just plan
> > to swap out the system entirely for a redesigned one?  Either position
> > is defensible.
> 
> I'd suggest going with a single choice and leave it at that. It will be
> good into the future, for as long as Subversion has existed in the past.
> Security-conscious people can immediately switch once we provide a new
> subsystem in ten years. Muggles will just naturally migrate as the update
> their svn installation.

We could use some marker-tag or header naming the algorithm, so upgrades can be done in a future-proof way, but actually implementing one single algorithm should be enough.

> > If you don't use CTR mode, you'll need to pick a reversible padding
> > function for the plaintext so that it matches a multiple of the
> > cipher's block size.  This is pretty simple.
> 
> In my wiki update, I mentioned 32 bits of random prefix (makes dictionary
> attacks even harder), and pad with NUL characters. AES uses
> 16 byte blocks, and keys of 16/24/32 bytes.

Padding with NUL characters opens a known plaintext window at the end of the passphrase. Maybe it's better to pad with random characters.

Hmm, I remember someone saying it's not easy to get crypto right, right? :-)

If there is no existing, well-known and trusted solution we can use (copy), we should at least try to get some review from some crypto experts for the design and the implementation.

Best regards

Markus Schaber
-- 
___________________________
We software Automation.

3S-Smart Software Solutions GmbH
Markus Schaber | Developer
Memminger Str. 151 | 87439 Kempten | Germany | Tel. +49-831-54031-0 | Fax +49-831-54031-50

Email: m.schaber@3s-software.com | Web: http://www.3s-software.com 
CoDeSys internet forum: http://forum.3s-software.com
Download CoDeSys sample projects: http://www.3s-software.com/index.shtml?sample_projects

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915