Yahoo has been accused for secretly building an app to bulk-scan customer emails at will at the request of US intelligence.

The app which was built in 2015 following a demand from the US government allowed the government to have access to emails of billions of yahoo users.The meek way in which Yahoo complied with the request reportedly led to the departure of the company’s chief information security officer, Alex Stamos, although Stamos has refused to comment on the situation.

The revelation was made late last night in a Reuters report quoting three former employees of the company, adding fuel to the crisis over the alleged hack of the company’s emails systems in 2014.

A former executive claimed recently that the hack affected all three billion or so accounts and not the 500 million to which Yahoo has admitted.

US telecoms and internet companies are known to have handed over bulk customer data to intelligence agencies, but former government officials and security experts polled by Reuters claimed that they had never heard of a company building its own application to effectively wiretap its own customers.

There are question marks over the legality of the US government demanding bulk data on US citizens’ emails, but those laws don’t apply to non-citizens.

There is justification for such demand in United State under the  2008 amendments to the Foreign Intelligence Surveillance Act.This allows the US government to demand customer data from US phone and internet companies that could help foreign intelligence-gathering under a number of justifications, including fighting terrorism.

Yahoo’s rivals in the industry, Google and Microsoft said they were yet to receive such demand from the government.