What is the difference between a hash collision and a pre-image attack?
In a collision, the adversary has much more freedom than in the pre-image attacks. An adversary has to choose two arbitrary (but different) inputs X and Y (of any size) yielding the same hash: h(X)=h(Y). In a second pre-image attack, the adversary is given a random input X (adversary has no control over the choice of X) and should find a different input Y with the same output. Such an attack is much harder than the collision attack. In a pre-image attack (against one-wayness), the adversary is given an output h(X) for a randomly chosen input X, and should find an input Y that gives the same output. Unlike in a second pre-image attack, the adversary is not given X directly.