How Is a Second-Preimage Attack Different from a First-Preimage Attack?
In a first-preimage attack, the attacker is given a hash output and must find any input that maps to it. In a second-preimage attack, the attacker is given an original input, M1, and its corresponding hash, H(M1), and must find a different input, M2, such that H(M2) = H(M1).
The second-preimage resistance property is crucial for integrity checks, as it prevents an attacker from replacing an original document with a fraudulent one that has the same hash.