Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep empty files unencrypted #162

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hugopeixoto
Copy link

@hugopeixoto hugopeixoto commented Oct 29, 2018

To work around the issue that git considers the working directory
dirty when empty files are encrypted, these are kept untouched when
cleaning/smudging.

Security wise, this is not an issue, as you can check if an encrypted
file is empty due to the deterministic encryption properties.

This fixes #53

@ticklemynausea
Copy link

This is being a real nuisance here for me too. What do we need to get this merged?

To work around the issue that git considers the working directory
dirty when empty files are encrypted, these are kept untouched when
cleaning/smudging.

Security wise, this is not an issue, as you can check if an encrypted
file is empty due to the deterministic encryption properties.
@hugopeixoto hugopeixoto force-pushed the fix/keep-empty-files-unencrypted branch from 62c3725 to 17a9020 Compare July 13, 2020 10:01
@hugopeixoto
Copy link
Author

I rebased this to the latest master

@AGWA
Copy link
Owner

AGWA commented Jul 29, 2020

I agree in principle that this is the correct fix.

Unfortunately, it's a breaking change to git-crypt's on-disk format. Empty files that were previously committed to the repo encrypted will now appear "modified" to Git. I'm not sure if there are other implications.

I think we need to find a way to apply this behavior to new but not existing git-crypt repos.

@hugopeixoto
Copy link
Author

hugopeixoto commented Jul 29, 2020

I think we can do that by setting a flag during git-crypt init, something like encrypt-empty-files=false which defaults to true if not set, and checking it on clean/smudge filters.

Initially I was thinking of making it a git-config, but the default files are not persisted across clones, so that wouldn't work. Maybe it could be stored in a file in .git-crypt/ and read by git-config --file? That would avoid adding too much parsing code.

Something like:

git config --file .git-crypt/config git-crypt.encrypt-empty-files

AGWA added a commit that referenced this pull request Jul 29, 2020
git has several problems with using smudge/clean filters
on empty files (see issue #53).  The easiest fix is to
just not encrypt empty files. Since it was already obvious
from the encrypted file length that a file was empty, skipping
empty files does not decrease security.

Since skipping empty files is a breaking change to the
git-crypt file format, we only do this on new repositories.
Specifically, we add a new critical header field to the key
file called skip_empty which is set in new keys.  We
skip empty files if and only if this field is present.

Closes: #53
Closes: #162
@AGWA
Copy link
Owner

AGWA commented Jul 29, 2020

The place to set this is in the key file, which is fortunately extensible. I've implemented this in #210. I would appreciate your testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue performing interactive rebases
3 participants