Bitcoin Forum
May 10, 2024, 12:51:34 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Encrypting directory ~/.electrum/wallets with a stacked file system  (Read 155 times)
chrade (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 8


View Profile
March 20, 2021, 09:06:15 AM
 #1

How about encrypting
Code:
/home/user/.electrum/wallets
for the case of unauthorized system access, with the stacked cryptographic fs https://nuetzlich.net/gocryptfs/?

The idea behind a cryptographic stacked file system https://wiki.archlinux.org/index.php/Data-at-rest_encryption#Stacked_filesystem_encryption is to selectively encrypt sensitive folders.

Move the directory wallets into a cipherdir, the lower directory, create an empty wallets directory at ~/.electrum/, the upper directory, where we mount the cipherdir before accessing our wallets and unmount the cipherdir after we close our wallets, with fusermount.

I've used gocryptfs for some weeks now, first on trivial data, and now on important data without any problems so far. It has a
Code:
-fsck
option to check the cipherdir for corruption.

Is this a good idea?
1715345494
Hero Member
*
Offline Offline

Posts: 1715345494

View Profile Personal Message (Offline)

Ignore
1715345494
Reply with quote  #2

1715345494
Report to moderator
"I'm sure that in 20 years there will either be very large transaction volume or no volume." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715345494
Hero Member
*
Offline Offline

Posts: 1715345494

View Profile Personal Message (Offline)

Ignore
1715345494
Reply with quote  #2

1715345494
Report to moderator
1715345494
Hero Member
*
Offline Offline

Posts: 1715345494

View Profile Personal Message (Offline)

Ignore
1715345494
Reply with quote  #2

1715345494
Report to moderator
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
March 20, 2021, 10:48:56 AM
 #2

I mean.. it depends.

It is not a bad idea. But if it is against unauthorized system access, you might as well just set an electrum password.
Electrum encrypts all the sensitive data with a key derived from your password. Use a strong enough passphrase, and you are fine. You don't need to use any external encryption (or even 2 encryption schemes).

Or are you concerned about a different attack vector? If it is just against unauthorized access, the electrum password is fine as long as you don't write it down on a piece of paper and stick it onto the monitor.

chrade (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 8


View Profile
March 20, 2021, 11:03:58 AM
 #3

Well I guess then, my idea is excessive Embarrassed, bob123.

A different attack vector, is if the laptop is stolen.

bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
March 20, 2021, 11:38:37 AM
 #4

A different attack vector, is if the laptop is stolen.

Well, this also falls under unauthorized access.

As long as the encryption is strong (strong algorithm, good implementation and strong passphrase), you are fine. Regardless of whether you use the electrum built-in encryption (which is AES-256 btw), or any external encryption software.

Electrums built-in password protection is already an encryption, no further encryption mechanisms required.  Smiley

chrade (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 8


View Profile
March 20, 2021, 12:05:51 PM
Last edit: March 20, 2021, 12:17:01 PM by chrade
 #5

Electrums built-in password protection is already an encryption, no further encryption mechanisms required.  Smiley

Thanks, I'll do as you suggest! I have a wallet password that is 16 chars long, I'll add a few more chars to it.

If that's your concern, you better encrypt whole disk/partition rather than specific directory. If you only encrypt specific directory, the theft still can access your personal data (e.g. browsing history) and log file (could be used to analyze your behavior).

For the moment I prefer a hybrid solution, as it does not slow down the system, and being a newbie with encryption systems, I am afraid I might ruin my whole OS installation.
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
March 20, 2021, 12:20:23 PM
 #6

Thanks, I'll do as you suggest! I have a wallet password that is 16 chars long, I'll add a few more chars to it.

No problem  Smiley

Make sure to pick a somewhat random password (no sentences, words, special dates, etc..).
16 chars is already a pretty good length. Depending on the charset, this should be sufficient already.



For the moment I prefer a hybrid solution, as it does not slow the system down, and as I am a newbie with encryption systems, I am afraid I might ruin my whole OS installation.

A somewhat modern system won't get slowed down much by full disk encryption.
The bottleneck most likely still will be the disk itself, instead of the additional operations required for encrypting/decrypting. But this obviously completely depends on your actual system.

chrade (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 8


View Profile
March 20, 2021, 12:31:09 PM
 #7

No problem  Smiley

Make sure to pick a somewhat random password (no sentences, words, special dates, etc..).
16 chars is already a pretty good length. Depending on the charset, this should be sufficient already.

I use passwords with a lot of special chars that don't make any sense.

A somewhat modern system won't get slowed down much by full disk encryption.
The bottleneck most likely still will be the disk itself, instead of the additional operations required for encrypting/decrypting. But this obviously completely depends on your actual system.

I use ubuntu 20.04 lts. The disk has many partitions with OS clones, KVM virtual machines .... I am afraid, based on my current skills, to complicate things any further.
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6734


bitcoincleanup.com / bitmixlist.org


View Profile WWW
March 21, 2021, 05:36:22 PM
 #8

Like any file system that's mounted with fusermount, this will require root access each time the folder is mounted when Electrum is started. Electrum currently doesn't need root permissions so making it request for its password or your own password if you use sudo opens up an additional vulnerability in that if your Electrum is boobytrapped, hackers will also have your OS password (as well as all your bitcoin), and can also do stuff like spawning a remote shell.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
chrade (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 8


View Profile
March 21, 2021, 05:47:43 PM
Last edit: March 21, 2021, 06:16:36 PM by chrade
Merited by ABCbits (1)
 #9

From the man page description:

Quote
Fusermount(1)
Filesystem  in  Userspace  (FUSE) is a simple interface for userspace programs to export a virtual filesystem to the Linux kernel. It  also aims  to  provide  a secure method for non privileged users to create and mount their own filesystem implementations.

From the gocryptfs https://github.com/rfjakob/gocryptfs/blob/master/Documentation/MANPAGE.md

Quote
-allow_other
By default, the Linux kernel prevents any other user (even root) to access a mounted FUSE filesystem. Settings this option allows access for other users, subject to file permission checking. Only works if user_allow_other is set in /etc/fuse.conf. This option is equivalent to "allow_other" plus "default_permissions" described in fuse 8.

Only if you pass the gocryptfs -allow_other option can root access the fuse mount, otherwise it's impossible, and as you see, it requires additional config to achieve this.
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6734


bitcoincleanup.com / bitmixlist.org


View Profile WWW
March 22, 2021, 05:43:52 AM
 #10

Only if you pass the gocryptfs -allow_other option can root access the fuse mount, otherwise it's impossible, and as you see, it requires additional config to achieve this.

That's great.

But what happens if Electrum won't start for some reason (or your computer dies) and you must manually copy the wallet file somewhere else?

It looks like each wallet file is encrypted by itself, so now there's an AES-encrypted file that you somehow have to decrypt before you can open it.

How can the wallet be decrypted in such cases? I have read from the tool website that there is a master key which allows for access but I'm not quite sure how to use it off-line if it's only printed at mount time:

The old principle still applies: Important data should have a backup. Also, keep a copy of your master key (printed on mount) in a safe place. This allows you to access the data even if the gocryptfs.conf config file is damaged or you lose the password.

Wallets definitely sound like important data to me. Does this mean we're also going to have an offline wallet backup stashed away somewhere on an external disk or USB?

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
chrade (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 8


View Profile
March 22, 2021, 01:09:36 PM
Last edit: March 22, 2021, 04:10:09 PM by chrade
Merited by ABCbits (1)
 #11

You can get the masterkey any time with
Code:
$ /usr/bin/gocryptfs-xray -dumpmasterkey myfs/gocryptfs.conf 

Whenever you print passwords in the terminal delete history with
Code:
$ cat /dev/null > ~/.bash_history ; history -c

But what happens if Electrum won't start for some reason (or your computer dies) and you must manually copy the wallet file somewhere else?

It looks like each wallet file is encrypted by itself, so now there's an AES-encrypted file that you somehow have to decrypt before you can open it.

How can the wallet be decrypted in such cases? I have read from the tool website that there is a master key which allows for access but I'm not quite sure how to use it off-line if it's only printed at mount time:

Wallets definitely sound like important data to me. Does this mean we're also going to have an offline wallet backup stashed away somewhere on an external disk or USB?

If you decide to use the gocryptfs for any data, there is a gocryptfs.conf file that you have to backup in case it gets corrupted, or you can you use the masterkey instead.

My concept to avoid being sorry as much as possible is make copies, copies, copies ...

I always have 3 bootable OSs with all their programs (home dir, etc) on my hard disk. I also have 2 external disks and each one has another 3 copies of the complete OS with everything. So at any given time I have 9 copies of everything that I try to update 3 times per month.

Every time I update, I boot a different clone just to make sure everything works. By the way you can copy the OS partition without loosing any file attributes from anywhere with
Code:
# rsync -aAHXsh --delete --preallocate --info=progress2,stats2 <source> <dest>
You have to run this as root from a live USB.

After doing this you have to change UUIDs of the updated partitions
Code:
$ lsblk -fm
to get the UUIDs
Code:
$ sudo nano <clone-path>/etc/fstab
to update UUIDs for /, /boot/efi and [SWAP] (if you have a swap partition)

You can boot with the http://www.rodsbooks.com/refind/ bootloader and install grub again with

Code:
sudo grub-install /dev/sdX
sudo update-grub

This means I also have 9 functional copies of my electrum wallets always.

In older times that I did not have the above concept, when I got a new hard disk, I created a new wallet with my seed.

Mind you external clones are not portable to other systems. They are bound to the system they were copied from.
chrade (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 8


View Profile
March 22, 2021, 03:42:15 PM
Last edit: March 22, 2021, 04:04:55 PM by chrade
 #12

I have to say it's quite a bit of work, especially manually changing UUID on fstab. Do you prioritize having OS with all application and files in any condition over convenience offered by backup software (such as timeshift)?

No offence, but after trying to recover a system state with timeshift once, and got left with an unbootable system, I do not want to try it again. IMHO,  timeshift is not worth anything, and the same goes for Mint that has timeshift as a pre-installed application; Mint that embraces MS concepts, like not being able to exclude certain updates.

Rsync options cannot fit in a gui in any sane way. Using a gui for critical tasks is way more dangerous than the cli. There's a reason why Ubuntu will not let you edit files as root in a gui text editor any more.

Changing UUIDs in /etc/fstab is just copying and pasting three strings, and nano editor is very easy to use, especially since I use a persistent (customizable) live USB, which you can create in debian based distros with https://help.ubuntu.com/community/mkusb.
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6734


bitcoincleanup.com / bitmixlist.org


View Profile WWW
March 22, 2021, 04:56:46 PM
 #13

I guess that you can make this a "wrapper" around Electrum in the sense that you make a script that installs gocryptfs, fuse and other dependencies, another script that decrypts the wallets folder before Electrum starts and encrypted it back again after it quits, and then a third script which you can use while Electrum is running to back up the wallet files, the gocryptfs keys, etc?

This all seems too complicated to merge into Electrum itself but it makes for a great implementation when coupled with a custom live ISO image.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
chrade (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 8


View Profile
March 22, 2021, 05:12:16 PM
 #14

I don't use scripts with gocryptfs.

Its commands are very simple.

Mount the cipherdir with
Code:
gocryptfs <cipherdir> <mountdir>

Unmount it with
Code:
fusermount -u <mountdir>
chrade (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 8


View Profile
March 23, 2021, 12:01:42 PM
Last edit: March 23, 2021, 02:47:16 PM by chrade
 #15

No offense taken, timeshift isn't great tool for those who can use rsync directly and know a bit about linux directory structure. IMO timeshift is worth for newbie (which uses default partition configuration without LVM/LUKS) or lazy users (who know how to restore the OS manually if timeshift break something).

I know it's easy, but it's annoying especially if you use LVM, LUKS or both of them.

I haven't used LVM (yet). When I started my current linux project I was (and still am) afraid of loosing mission critical data with LVM. Do be honest, I have to do some additional learning concerning LVM. I might try it in a future project without grouping physical volumes.

At the moment I use gpt partitioning with ext4 partitions.

Haven't tried LUKS either or any other block device encryption (yet). To this respect I am also worried about an additional point of failure, possible increase of hardware wear, ...

For now I like the simplicity of a stacked FS, and the option of having certain folders encrypted, while actually operating the system.

Having said all that, I am always open to new ideas and reconsidering my points of view. Smiley
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6734


bitcoincleanup.com / bitmixlist.org


View Profile WWW
March 23, 2021, 06:34:51 PM
 #16

Haven't tried LUKS either or any other block device encryption (yet). To this respect I am also worried about an additional point of failure, possible increase of hardware wear, ...

LUKS will only benefit you if someone like your local police department physically takes the hard drive out of the computer and takes it away. It's more likely to give you headaches with data recovery because restoring LUKS partitions is convoluted. A single bad modification to the partition can cause total data loss, which you do not want to deal with on a disk with wallet.dat files.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
chrade (OP)
Newbie
*
Offline Offline

Activity: 21
Merit: 8


View Profile
March 23, 2021, 06:45:37 PM
 #17

LUKS will only benefit you if someone like your local police department physically takes the hard drive out of the computer and takes it away. It's more likely to give you headaches with data recovery because restoring LUKS partitions is convoluted. A single bad modification to the partition can cause total data loss, which you do not want to deal with on a disk with wallet.dat files.

That's exactly the sort of thing I can live without!!

I'm quoting a relevant comment from Dave McKay from an excellent tutorial on the use of gocryptfs at https://www.howtogeek.com/686779/how-to-encrypt-files-with-gocryptfs-on-linux/
Quote
Simple systems have the advantage of being used more often, while more complicated processes tend to fall by the wayside. Using gocryptfs is not only simple, it’s also secure. Simplicity without security wouldn’t be worthwhile.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!