Yahoo Inc. will undoubtedly face backlash over the revelation that it scanned all its users’ incoming emails. But experts say that Yahoo has strong defenses against potential lawsuits relating to the spying.

According to a Reuters report Tuesday night, Yahoo complied with orders from the National Security Agency or the Federal Bureau of Investigation last year to search all incoming emails on its platform for a specific signature, such as a phrase or an attachment. The surveillance program has since ended. The New York Times reported Wednesday that Yahoo received the surveillance order from the Foreign Intelligence Surveillance Court.