The mass collection of American phone records and metadata by the National Security Agency (NSA) has been ruled illegal by a US appeals court, reports the BBC.

The decision made by three federal judges overturns a 2013 ruling and, while it does not bring an end to the program, urges Congress to either halt or replace the surveillance activity. The controversial monitoring of phone records was first exposed by whistleblower Edward Snowden, the former NSA contractor who has since fled to Russia.

Members of Congress are expected to vote on the USA Freedom Act next week, a bill that could end the bulk collection of telephone data. Meanwhile, the section of the USA Patriot Act that it would effectively replace is due to expire in June, although some senators are seeking an extension.

Speaking on Section 215 of the Patriot Act, which addresses the FBI's ability to gather business records, Judge Gerard Lynch said that it could not be interpreted to grant permission to gather such a large amount of phone records, despite the claims of some senators.

"Such expansive development of government repositories of formerly private records would be an unprecedented contraction of the privacy expectations of all Americans," Lynch wrote in a 97-page document (PDF here). "We would expect such a momentous decision to be preceded by substantial debate, and expressed in unmistakable language. There is no evidence of such a debate."

Last year, ESET's senior security research Stephen Cobb examined the revelations around NSA surveillance, looking specifically at how it could affect online behavior and the economy.

Photo: 360b / Shutterstock.com