Encryption is not authenticated.
KeePass Command Line Interface
Brought to you by:
hightowe,
perlsaiyan
This may be an extension of KeePass proper, but the database is not authenticated with a MAC. The subroutine "encrypt_rijndael_cbc" uses Crypt::Rijndael::MODE_CBC without any authentication. This leaves the DB as malleable. A MAC tag needs to be generated, and subroutine decrypt_rijndael_cbc should exit, if the calculated MAC tag and attached MAC tag do not match, before decrypting.
Looks like this is a problem with upstream KeePass proper. See https://sourceforge.net/p/keepass/discussion/329220/thread/f2257039/
Hmm. That might not be correct. Line 538 appears to be MAC-then-Encrypt.
The line of code that you pointed out -- this one:
is used only to detect if the Keepass file that kpcli has opened changes on disk underneath it, most likely due to the user concurrently using more than one Keepass client on the file. That MD5 hash is used exclusively to detect and warn a user if the file has canged under them, when they have asked to save the state that kpcli has to that file.
I do think you are correct about the overall problem, but it is not a kpcli problem but rather a Keepass issue.