In a hard-hitting ruling made public Thursday, Justice Simon Noel said the Canadian Security Intelligence Service breached its duty to inform the court of its data-collection program, since the information was gathered using judicial warrants.

CSIS should not have retained the information since it was not directly related to threats to the security of Canada, the ruling said.

“Ultimately, the rule of law must prevail,” Noel wrote, adding, “without it, the actions of people and institutions cannot be trusted to accurately reflect the purpose they were entrusted to fulfil.”

CSIS crunched the data beginning in 2006 using a powerful program known as the Operational Data Analysis Centre to produce intelligence that can reveal specific, intimate details about people the spy service investigates, the judge says.

The improperly retained material was metadata — information associated with a communication, such as a telephone number or email address, but not the message itself.

However, it is difficult to determine the precise nature of the metadata involved due to heavy redactions to the 126-page court ruling.

The ruling said the CSIS data analysis grew out of the spy service’s concerns in the early 2000s that the information it collected was not fully utilized and should be processed using modern techniques.

That should not mean an expansion of the CSIS mandate approved by Parliament, Noel wrote.

“The evolution of technology is no excuse to flout or stretch legal parameters. When the information collected does not fall within the legal parameters delimiting the agency’s functions and actions, it cannot legally be retained.”

In the decision, Noel said he considered ordering the destruction of the associated data collected since 2006, but decided against it because, in part, he did not hear legal arguments on the question.

He suggested it may be time to revisit the CSIS Act of 1984, which is “showing its age” in a technologically advanced world.

“Canada can only gain from weighing such important issues once again,” Noel wrote. “Canadian intelligence agencies should be provided the proper tools for their operations but the public must be knowledgeable of some of their ways of operating.”