Canada's two spy agencies have come under attack by their Ottawa watchdogs for breaking the rules of telecommunications surveillance.

A report released on Thursday revealed that the Communications Security Establishment (CSE) has unlawfully shared data with foreign allies, while a report on the Canadian Security Intelligence Service made public on the same day said CSIS has been neglecting to tell judges who authorize surveillance operations they are retaining elements of communications intercepts they are ordered to destroy.

The reports from the watchdogs for CSE and CSIS centred on "metadata," or the intercepted telecommunications trails reflected in phone logs and Internet protocol (IP) exchanges. Collecting and sharing such material can vastly expand intelligence-gathering operations. The legal issues this raises have been quietly debated over the past 15 years within Canada's intelligence bureaucracy, but not in open courts or Parliament.

Story continues below advertisement

The new Liberal government came to office last fall pledging to make the country's spies more accountable and transparent, but highly classified and complex surveillance programs that have proliferated in secrecy over the past decade indicate how difficult that promise may be to fulfill.

Together, the CSE and CSIS get more than $1-billion from taxpayers. Both are banned from spying on Canadians without a warrant.

Government officials played down the significance of potential privacy breaches.

In discussing one watchdog report, the minister responsible for CSE, Ottawa's ultra-secretive electronic spy agency, said he was unable to say how many Canadians were affected by the sharing of the metadata in 2013, or why it took until 2016 to disclose it.

"I can't give you the actual number, because the way I am informed is that … we would be violating the law in digging up that type of information," Defence Minister Harjit Sajjan told reporters.

Jean-Pierre Plouffe, a retired judge who acts as CSE's watchdog commissioner, said in his report that the spy agency broke rules by passing metadata involving the communications of Canadians to its closest foreign allies, a group collectively known as "the Five Eyes."

Experts say this is the first time in CSE's modern existence that it has been found to have acted unlawfully. "I believe this is the first clear instance of a commissioner declaring that CSE did not comply with the law," said Bill Robinson, a researcher whose blog is devoted to the spy agency.

Story continues below advertisement

The Five Eyes have existed since the Second World War, when signals intelligence agencies in Canada, the United States, Britain, Australia and New Zealand teamed up to spy on foreign adversaries. Today, the shared work continues, as the CSE and its counterparts analyze phone logs, Internet IP routing information, and other data trails that are captured through clandestine means on a massive, global scale.

All this is done so security agents can spot threats, or figure out who is talking to whom, even when they cannot snoop on the underlying conversations or messages. Sometimes this helps set up more targeted and invasive spying operations.

The danger with metadata is that spy agencies can break domestic-surveillance laws when they collect and share it in bulk. CSE says it only ever "incidentally" captures Canadian communications and works to protect privacy when it inevitably does.

Mr. Plouffe said the spy agency's breaches in 2013 were "not intentional," but that CSE did not exercise "due diligence when it failed to ensure that the Canadian identity information" was not included in reports given to allies. (Prosecutors decided not to lay charges after being assured by Mr. Plouffe it was unlikely that any Canadian identities were actually compromised.)

Faced with the adverse findings in the watchdog's annual report, CSE held an unprecedented technical briefing for reporters in Ottawa – the first time the agency has done so.

Officials blamed a software problem, and said CSE stopped sharing the problematic information in 2014. Reporters were told the metadata did not contain the names of any Canadians, and that the CSE was confident that none of the allied agencies, including the U.S. National Security Agency, would have used the information to target Canadians.

Story continues below advertisement

Because CSE eavesdrops on foreigners, it needs legal authorization from the Minister of National Defence. On Thursday, Mr. Sajjan pointed out to reporters that "the actual deficiency was identified by CSE officials themselves and they proactively brought that to the attention of the [watchdog] commissioner."

CSIS – the "human intelligence" counterpart to CSE's "signals intelligence" service – was also criticized on Thursday for previously undisclosed efforts to collect metadata.

Because CSIS intelligence officers mostly focus on Canadian targets, they need authorization from Federal Court judges for any bugging or hacking operations. When warrants expire, CSIS is legally obliged to destroy the captured communications of people it did not specifically "target" in a surveillance operation.

Years ago, CSIS leaders decided officers could retain the metadata related to all intercepted communications, even if forced to destroy the contents of underlying conversations. The report on CSIS that was released on Thursday, written by the watchdog Security Intelligence Review Committee (SIRC), said the agency never revealed this practice to the judges who authorized the intercepts.

The report recommends that CSIS now do so each time it asks for a warrant.

"SIRC was given no indication that the Service was fully transparent with the Federal Court about the nature and scope of its activities with respect to metadata," it reads. The report urges CSIS to disclose to judges what it has been doing, because "the court has a general interest in how the service uses the intelligence, including metadata, collected under the authority of a warrant."

Story continues below advertisement

In its response, CSIS says it disagrees with the finding and that it has "communicated clearly and transparently to the Federal Court."