PBEWithMD5AndDES Cipher does not check for integrity first? I am running FindBugs with findsecbugs plugin to scan java code for security issues. I am getting "Cipher With No Integrity" error for a Cipher function implemented with "PBEWithMD5AndDES". The legend says "The ciphertext produced is susceptible to alteration by an adversary. This mean that the cipher provides no way to detect that the data has been tampered with. If the ciphertext can be controlled by an attacker, it could be altered without detection."

For the solution it suggests to "Use a cipher that includes a Hash based Message Authentication Code (HMAC) to sign the data. Combining a HMAC function to the existing cipher is prone to error. Specifically, it is always recommended that you be able to verify the HMAC first, and only if the data is unmodified, do you then perform any cryptographic functions on the data." Examples at http://find-sec-bugs.github.io/bugs.htm#CIPHER_INTEGRITY

My statement is like below

Cipher engine = Cipher.getInstance("PBEWithMD5AndDES");


Doesn't the "PBEWithMD5AndDES" option verify the HMAC first? Or should I use other cipher option like "AES/GCM/NoPadding" as suggested?
Password-based encryption uses a hash function to derive a key from a password and that is the only use of a hash function. PBEWithMD5AndDES itself doesn't provide any authentication (includes integrity) and only uses MD5 for key derivation.

If you want authentication, then you can still use PBEWithMD5AndDES, but you then would have to derive a MAC key from the password yourself and generate an authentication tag by running HMAC(ciphertext, macKey).

But it is not recommended to use DES or even MD5 nowadays, so you should change the encryption scheme nevertheless. If you do, then you can exchange it with AES-GCM which already provides authentication. You still would need to derive a key from a password that you provide. There are many key-derivation functions, but Java provides PBKDF2 in the standard library. Alternatives are scrypt, bcrypt and Argon2.