crouton icon indicating copy to clipboard operation
crouton copied to clipboard

Unencrypted keys in user directory for single-password access (from #1399)

Open Timvrakas opened this issue 9 years ago • 22 comments

NOTE: Continuation of #1399

OK here it is!

Adds new encryption system that uses unencrypted keys the the encrypted user partition, to allow for easier encrypted login. edit-chroot -u or mount-chroot -u will create the keys, and they will be detected from then on.

I think edit-chroot and mount-chroot are good to go. I tested them on my C720 I am unsure if (or how) I should edit main.sh and add an option to set this up on creation of a chroot, for now you have to run edit-chroot -u or mount-chroot -u to create the keys.

I'm still new to all this (crouton, git, bash, life) so feel free to offer comments, questions, concerns, criticisms, critiques, complaints.

Thanks!

Timvrakas avatar Apr 06 '15 20:04 Timvrakas

Thanks for working on this!

I don't think there needs to be a new parameter, though. When you go to encrypt the chroot, and only if you specify the -k parameter, you should be allowed to leave the passphrase empty. crouton should confirm that you want to leave the passphrase in the clear, and note that this should only be done if the keyfile is located in encrypted storage (such as your user profile) or on removable media. When you go to mount the chroot, the chroot should automatically find the unwrapped key (as it already does for -k).

dnschneid avatar Apr 06 '15 22:04 dnschneid

@dnschneid I will get on that. It shouldn't take so long now that i'm familiar with the code.

On an off topic git-related tangent, If I want to roll back my current commit, and start fresh (I think that would be easiest), should I git revert or git reset --hard and then push --force? I looked it up, but I'm unsure which is correct.

Thanks

Timvrakas avatar Apr 07 '15 13:04 Timvrakas

If you want to start fresh and throw away the work, git reset --hard origin/master followed by git push origin encryption --force-with-lease will safely update github.

dnschneid avatar Apr 07 '15 18:04 dnschneid

OK thanks for the tip.

The question I have with the -k parameter is that if .ecryptfs is a pointer for the moved keyfile, then the only location for the keys is in the user directory, which is lost if the user account is deleted. I would prefer to have the keys in 2 places, both encrypted in the folder of the chroot and decrypted in the user home (this is especially true with separate-partition).

Any suggestions for this?

Timvrakas avatar Apr 07 '15 20:04 Timvrakas

That's kind of the point of moving the key around. You can manually back up your key somewhere else (and then point to it if need-be by passing -k to enter-chroot), but for security, crouton shouldn't be silently duplicating your keys in multiple places.

dnschneid avatar Apr 07 '15 20:04 dnschneid

Is that the sort of change you were looking for? I guess that makes more sense. FYI the previous commit was moved to timvrakas/old-encryption WARNING: The above not tested, I will not have access to my chrome book until later tomorrow.

Timvrakas avatar Apr 09 '15 05:04 Timvrakas

But yes, this was pretty much how I was expecting it to behave (kudos for the very clean way of handling the unwrapped keys).

dnschneid avatar Apr 09 '15 21:04 dnschneid

I still have a problem. They 63-char keys are coming back to haunt me. They are not properly handled. But It should be good otherwise.

Timvrakas avatar Apr 09 '15 21:04 Timvrakas

Is hexdump still giving you a bad byte count, even with the 32/1 update? It seemed fixed to me.

dnschneid avatar Apr 09 '15 22:04 dnschneid

The issue with the hexdump is that old keys (made before the fix) are still too short. I will have to do line-by-line separation.

Timvrakas avatar Apr 09 '15 22:04 Timvrakas

Good point. I don't think you need to do line-by-line though. Something like:

If first 16 characters of key is ....., it's unencrypted (don't check fnek to confirm). Then you can easily extract the keys (which are just hex):

contents="`tail -n+1 keyfile`"
key="${contents#${DOTS}}"
key="${key%%.*}"
fnek="${contents##*.}"

dnschneid avatar Apr 09 '15 23:04 dnschneid

OK I finished testing and worked out a few bugs. It all works for the most parts. TODO:

  1. Deal with the malformed (short) keys (as mentioned above)
  2. The -ee change password should check for request password.
  3. Link empty-password to -k flag (as mentioned above)

Timvrakas avatar Apr 10 '15 00:04 Timvrakas

Well this is going to sound lame, but I just lost the completed above TODO. Somebody pressed the spacebar..... grr. I will have it done again in a few days.

Timvrakas avatar Apr 19 '15 23:04 Timvrakas

Whoops! No rush :)

dnschneid avatar Apr 21 '15 01:04 dnschneid

Haha, well it looks like I got side-tracked for a long time.... Anyway now I have to deal with the new echo_tty functions

** Rebased and dealt with echo_tty **

Timvrakas avatar May 09 '15 23:05 Timvrakas

This is shaping up very well!

dnschneid avatar May 16 '15 19:05 dnschneid

The last thing I'd like to see is additions to the 17-encryption tests to handle no passwords (both with -k and without -k specified).

dnschneid avatar May 16 '15 20:05 dnschneid

Considering how critical this is to users' data, I can't merge this unless there are tests in place to prove it works. Could you add tests to 17-encryption to stress the new code paths?

dnschneid avatar May 27 '15 01:05 dnschneid

OK, I'm still figuring out the testing architecture, But I will figure it out eventually.

Timvrakas avatar May 27 '15 14:05 Timvrakas

@Timvrakas shouldn't be too complex (you can run the encryption tests on your device by dropping the repo outside your chroot and running ./test/run.sh 17). If you need help, swing by #crouton-devel for advice. It'd be awesome to get this feature merged, but we have to be careful.

dnschneid avatar May 29 '15 07:05 dnschneid

Much simpler to just store some long random password in the home folder, then modify mount-chroot to read it out. Additionally I recommend moving all the scripts from /usr/local/bin to within the eCryptfs home folder (i.e. /home/chronos/user/crouton/) and making a symlink to the chroot storage (i.e. /home/chronos/user/chroot)

mount-chroot:
...
PWFILE="/home/chronos/user/crouton/pwfile"
...
            if [ -e "$PWFILE" ]; then
                passphrase="`cat $PWFILE`"
            else
                echo_tty -n "Enter encryption passphrase for $NAME: "
                [ -t 0 ] && stty -echo
                if [ -z "$passphrase" ]; then
                    read -r passphrase
                fi
                [ -t 0 ] && stty echo
                echo_tty ''
            fi
...

gbrld avatar Dec 05 '16 09:12 gbrld

Much simpler to just store some long random password in the home folder, then modify mount-chroot to read it out.

The password would have to have as many bits of entropy as the key itself, assuming the wrapping function actually can use that much data. Seems like one way or another this would weaken the chroot protection somewhat, compared to storing the key directly in encrypted storage. Of course, it's still better (and more convenient) than the current approach.

Additionally I recommend moving all the scripts from /usr/local/bin to within the eCryptfs home folder (i.e. /home/chronos/user/crouton/) and making a symlink to the chroot storage (i.e. /home/chronos/user/chroot)

This is also very prudent. To be clear, you have to run the scripts directly from the encrypted storage.

dnschneid avatar Dec 20 '16 21:12 dnschneid