How do routers. switches, bridges and hubs deal with corrupted data?
Frames and packets failing the integrity test (by FCS or header checksum) are dropped.
By data corruption I mean frame/packet corruption, we can stick to the corruption due to a collision for simplicity.
A collision fragment is not considered a corrupt frame, it is always dropped. Since the FCS is at the end of a frame it hasn't been transmitted on collided frames yet. (Assuming the network is working normally and there are no late collisions.)
Collisions are detected on the physical layer and retransmission is scheduled immediately. A frame is only deleted from the sender's buffer when it has been transmitted in entirety.
Of course, repeaters, half-duplex transmission and CSMA/CD are all but obsolete today.
I know that switches can detect frame corruption if they are not set to cut-through forwarding.
Cut-through switches also detect FCS failure but have already finished forwarding when they do. Most often, a FCS failure rate above a certain level switches the forwarding to store-and-forward to avoid forwarding corrupt frames.
But are they always doing it ? And how does a switch detect a corruption?
They do it all the time by recalculating the FCS and comparing it to the frame's one.
I have read that similar mechanisms (cut-through and store-and-forward) can be found in routers.
Most routers use store-and-forward but that doesn't really matter.
So do routers detect packet corruption in the same way as switches do ?
For IPv4, routers check the header checksum (and recalculate it when forwarding). IPv6 headers carry no checksum, so v6 packets cannot be checked. Neither checks the integrity of user data (L4+).
Of course, routers also check the FCS for received frames or any other checksum providing by the link layer in use - other protocols than Ethernet do exist.
Finally hubs. Can they detect any data corruption or are they always forwarding data without any checks ?
Hubs have no concept for anything but channel bits or symbols. They cannot check for corruption nor do they need to. Since forwarding is done immediately, bit for bit, the receiving node will check the frame's integrity.