And even if the leading car was non-malicious and merely incompetent, it's your responsibility to not hit anything in front of you. For liability, you worry about what's in front, not what's behind.
The only way you get out of being liable for rear-ending someone is if the leading car maliciously caused you to rear-end them, or if something unpredictable happened that would have made it impossible for you to avoid hitting the other car.