Skip to content

Vim cryptmethod is not authenticated #638

@atoponce

Description

@atoponce

When using cryptmethod=blowfish2, the saved ciphertext is not authenticated with a message authentication code ("MAC tag"). Consider saving "Lorem ipsum dolor sit amet, consectetur adipiscing elit." to a text file, and getting the SHA-256 digest of the ciphertext:

$ vim -x /tmp/lorem.txt
(Use "vim" as the passphrase)
$ sha256sum /tmp/lorem.txt
510e57357353d511dac719bc238900456332ca0e4c00bcf12d244fdc66355f8e  /tmp/lorem.txt

Now deliberately corrupt the file:

$ dd seek=50 conv=notrunc bs=1 count=10 if=/dev/urandom of=/tmp/lorem.txt
10+0 records in
10+0 records out
10 bytes copied, 0.000293754 s, 34.0 kB/s

Notice the SHA-256 digest has changed. Open the file, and notice that the plaintext has changed:

$ sha256sum /tmp/lorem.txt 
f17d3494643ed8bef5f0ba7fd67af6682f0332a0bccf52e9a2640604bec0b111  /tmp/lorem.txt
$ vim -x /tmp/lorem.txt
(Use "vim" as the passphrase)

I get "Lorem ipsum dolor sit £ÕH<8a>`7^T¸³­#÷f;Qüצadipiscing elit." returned. Your mileage may vary.

If the ciphertext was authenticated with a cryptographically secure hashing function (Skein by Bruce Schneier would be fitting, given the use of his Blowfish algorithm as the symmetric cipher), and if the MAC tag was calculated on the ciphertext, then when attempting to decrypt, if the MAC tag did not match the newly calculated MAC tag, Vim should error out, rather than decrypting and displaying the file. See the Wikipedia article on "Encrypt-then-MAC".

Vim should use "Encrypt-then-MAC" authenticated encryption when using cryptmethod.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions