Mark Zuckerberg of Facebook and Marissa Mayer, the CEO of Yahoo, struck back on Wednesday at critics who have charged tech companies with doing too little to fight off NSA surveillance. Mayer said executives faced jail if they revealed government secrets.

Yahoo and Facebook, along with other tech firms, are pushing for the right to be allowed to publish the number of requests they receive from the spy agency. Companies are forbidden by law to disclose how much data they provide.

During an interview at the Techcrunch Disrupt conference in San Francisco, Mayer was asked why tech companies had not simply decided to tell the public more about what the US surveillance industry was up to. "Releasing classified information is treason and you are incarcerated," she said.

Mayer said she was "proud to be part of an organisation that from the beginning, in 2007, has been sceptical of – and has been scrutinizing – those requests [from the NSA]."

Yahoo has previously unsuccessfully sued the foreign intelligence surveillance (Fisa) court, which provides the legal framework for NSA surveillance. In 2007 it asked to be allowed to publish details of requests it receives from the spy agency. "When you lose and you don't comply, it's treason," said Mayer. "We think it makes more sense to work within the system," she said.

Zuckerberg said the government had done a "bad job" of balancing people's privacy and its duty to protect. "Frankly I think the government blew it," he said.

He said after the news broke in the Guardian and the Washington Post about Prism, the government surveillance programme that targets major internet companies: "The government response was, 'Oh don't worry, we're not spying on any Americans.' Oh, wonderful: that's really helpful to companies trying to serve people around the world, and that's really going to inspire confidence in American internet companies."

"I thought that was really bad," he said. Zuckerberg said Facebook and others were pushing successfully for more transparency. "We are not at the end of this. I wish that the government would be more proactive about communicating. We are not psyched that we had to sue in order to get this and we take it very seriously," he said.

On Monday, executives from Yahoo, Facebook, Google and other tech leaders met the president's group on intelligence and communications, tasked with reviewing the US's intelligence and communications technologies in the wake of the NSA revelations.

The meeting came as Yahoo and Facebook filed suits once more to force the Fisa court to allow them to disclose more information.

In its motion, Yahoo said: "Yahoo has been unable to engage fully in the debate about whether the government has properly used its powers, because the government has placed a prior restraint on Yahoo's speech."

It went on: "Yahoo's inability to respond to news reports has harmed its reputation and has undermined its business not only in the United States but worldwide. Yahoo cannot respond to such reports with mere generalities," the company said.

Microsoft and Google also filed their latest legal briefs on Monday to force the Fisa court to disclose more information.

In a blogpost, Google said it was asking for permission to publish "detailed statistics about the types (if any) of national security requests" it receives under Fisa.

"Given the important public policy issues at stake, we have also asked the court to hold its hearing in open rather than behind closed doors. It's time for more transparency," said Google.