WannaCry exploited a vulnerability in Windows, specifically through the EternalBlue exploit, which was developed by the National Security Agency (NSA) and later leaked by the Shadow Brokers hacker group. The ransomware propagated like a highly infectious disease, moving rapidly through networks by exploiting this vulnerability.