16

I know using :set cryptmethod=zip is not secure, but how secure is using :set cryptmethod=blowfish?

On wikipedia I read that the blowfish cipher, as such, should be secure, but this says nothing about the security of Vim's implementation of it.

And what about swapfiles, backupfiles, undofiles, and other possible ways to bypass the blowfish encryption? How secure is Vim there?

  • 1
    Won't this really be better off at Information Security, given that you have already identified the algorithm(s) being used? – muru Feb 4 '15 at 22:49
  • Hmm. The docs are a bit confusing here. :h encryption says undo and swap files are encrypted in both 7.3 and 7.4, yet :h cryptmethod in 7.4 makes explicit mention of the undo file only for blowfish2. – muru Feb 4 '15 at 23:00
  • 2
    @muru It's a question about Vim's implementation of blowfish-based encryption, not about the blowfish algorithm itself. This question would also be on-topic on Information Security, but that doesn't make it off-topic here. The answer is, in fact, that blowfish itself is secure (even if it isn't the best choice), but that Vim's implementation of it is bad. – Gilles 'SO- stop being evil' Feb 5 '15 at 0:17
20

It is not secure. David Leadbeater posted POC code to brute-force upto 64 bytes in an article titled, somewhat ironically, Vim blowfish encryption... or why you shouldn't roll your own crypto. The Vim documentation now recommends:

- The implementation of 'cryptmethod' "blowfish" has a flaw.  It is possible
  to crack the first 64 bytes of a file and in some circumstances more of the
  file. Use of it is not recommended, but it's still the strongest method
  supported by Vim 7.3 and 7.4.  The "zip" method is even weaker.

And, earlier on:

The text in the swap file and the undo file is also encrypted.  E843
However, this is done block-by-block and may reduce the time needed to crack a
password.  You can disable the swap file, but then a crash will cause you to
lose your work.  The undo file can be disabled without much disadvantage. 
        :set noundofile
        :noswapfile edit secrets

Note: The text in memory is not encrypted.  A system administrator may be able
to see your text while you are editing it.  When filtering text with
":!filter" or using ":w !command" the text is also not encrypted, this may
reveal it to others.  The 'viminfo' file is not encrypted.

Summary:

  • If you care about security, blowfish should not be used. Use blowfish2 instead.
  • While swap and undo files are encrypted, viminfo isn't.

Unsolicited advice:

  • If you do care about security, do not roll your own encryption. And that means the blowfish2 implementation as well. Use something else, like GPG. The gnupg.vim plugin may be useful. It seems to be maintained. It disables viminfo and the swap file.
| improve this answer | |
  • 1
    The claim by David Leadbeater in (dgl.cx/2014/10/vim-blowfish) the last para is using a dictionary for bruteforce attack. He then adds "small passwords" would weak. His theoretical arguments are correct but not practical. Good 64 bit or more random passwords are uncrackable. – mosh Aug 30 '16 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.