It's not just WD NAS that are facing issues like this. I have a QNAP, so I follow news on that and they've been getting hit repeatedly with ransomware cryptolockers recently as well.
It's nearly always UPNP that's causing the device to be exposed unknowingly to the internet and then a some software bug that allows the exploit.