Paying a ransom requested by ransomware is not illegal. However, the FBI discourages doing so. According to the FBI, paying a ransom doesn’t guarantee that you’d gain access to your data and may encourage more ransomware attacks.