Five Eyes allies identified a diplomatic data link between Chinese offices as a target for hacking. Nicky Hager and Ryan Gallagher dissect the plan.
On Auckland's busy Great South Rd in the suburb of Greenlane, the Chinese consulate, a white modern building, is tucked behind a row of bushes and small trees.
A five-minute walk down the road, opposite a cafe, is a smaller, grey building that houses the Chinese Visa Office. Between the two is a data link used to transmit diplomatic communications. In 2013, New Zealand's spies hatched a top-secret plan to hack into it.
The operation, a joint project with the US National Security Agency (NSA), is revealed in classified documents seen by the Herald on Sunday.
The files show how, under the John Key National Government, spying has been prioritised against China, New Zealand's largest and most important trading partner.
A 2013 NSA document placed "collection on China" first on a list of targets monitored by the Government Communications Security Bureau (GCSB) on behalf of the NSA.
The GCSB "continues to be especially helpful in its ability to provide NSA ready access to areas and countries that are difficult for the United States to access", the report said. The secret documents revealing the surveillance were analysed by the Herald on Sunday in collaboration with the US news website The Intercept, which obtained them from the NSA whistle-blower Edward Snowden.
The documents highlight a two-faced New Zealand government policy towards China and raise questions about whether the GCSB has violated international treaties that prohibit the interception of diplomatic communications.
Publicly, the government has declared a good relationship with China is crucial to New Zealand's economic future. Key has talked about expanding links to grow trade and explore other opportunities with the North Asian economic powerhouse. Since the Free Trade Agreement was signed in Beijing in 2008 - after 15 rounds of talks over three years - two-way trade is worth $20 billion a year and rising.
But it is fragile. Scares such as the Fonterra botulism milk powder recall risk the relationship, and Australia has recently signed an FTA with China, prompting concern that could affect our existing deal.
At a Beijing meeting with the Chinese President, Xi Jinping, in March last year, Key said: "This relationship has never been stronger."
Xi Jinping visited New Zealand later that year, stating the China-New Zealand relationship was based on friendly co-operation and mutual respect, and "set a fine example for the pursuit of successful state-to-state relations".
Key replied that he looked forward to "seeing how we can take our relationship to an even greater height". The relationship was not "purely trading", he said. "It is so much broader and much deeper than that."
But, as minister in charge of the GCSB, Key was also overseeing the plot to spy on China, which included the top-secret planned operation against the Chinese consulate in Auckland.
The joint GCSB-NSA operation is outlined in a document called NSA Activities in Progress 2013. One of two New Zealand items on this list is "New Zealand: Joint effort to exploit Chinese MFA [Ministry of Foreign Affairs] link".
This high-stakes operation targeted communications passing between the two Chinese government buildings on Great South Rd.
Another NSA document dated April 2013 said the GCSB had "identified an MFA data link between the Chinese consulate and Chinese Visa Office in Auckland". The NSA and GCSB agreed to work together to eavesdrop on the Chinese communications carried on this link.
Because of the time-frame they cover, the Snowden documents do not reveal whether the operation was completed.
In May 2013, Snowden left his Hawaii-based intelligence job and flew to Hong Kong carrying the cache of secret files. In the weeks before his departure, the consulate project had been agreed and was actively being planned, but it was not yet fully under way.
The consulate spying project appeared to be called "GCSB Project Frostbite". It had a separate name inside the NSA: Project Basilhayden.
The April 2013 document said that "formal co-ordination" on the eavesdropping plan had begun between the NSA and GCSB.
The GCSB was "providing additional technical data on the [Chinese Consulate] link to TAO", the NSA's powerful Tailored Access Operations division that hacks into target computer systems and networks, such as the data link, to intercept communications and data.
A further NSA document, a monthly report written in March 2013 by the NSA's Special US Liaison Officer in Wellington, said the GCSB was drafting a paper on Project Frostbite that "outlines the interaction with TAO for this activity".
The document, to be signed by the GCSB director, would "answer questions by TAO on the operation that will allow it to go forward".
Matthew Aid, an American intelligence expert and author of a book on the NSA, reported in Foreign Policy magazine in 2013 that the TAO had successfully been penetrating Chinese computer and telecommunications systems for almost 15 years, in what the NSA calls computer network exploitation, or CNE. The GCSB's role in hacking operations is lesser known. But the agency has a secretive hacking unit in its Operations Division, based at its Wellington headquarters, that is devoted to network analysis. It is probably these staff who studied the Chinese consulate facilities and found the data link.
The April 2013 report said: "NSA and GCSB have verbally agreed to move forward with a co-operative passive and active effort against this link." Passive surveillance refers to eavesdropping on communications as they are flowing over cables or between satellites.
Active surveillance surveillance is a more aggressive method that involves hacking into computers or networks; it could involve planting spyware in the Auckland-based Chinese government computers or routers.
It is a serious step for the Government to co-operate in spying on consular communications. New Zealand has signed the 1961 Vienna Convention on Diplomatic Relations and the 1963 Vienna Convention on Consular Relations, international treaties that protect the "inviolability" of consulates and their communications.
Key said recently that New Zealand was "known for its integrity, reliability and independence", and had an obligation to support the rule of law internationally.
Government insiders say New Zealand's Ministry of Foreign Affairs and Trade has been worried about the GCSB's China plot becoming public since the Snowden leaks appeared in mid-2013.
The sources say former diplomat and defence secretary John McKinnon was brought out of retirement and posted to Beijing as New Zealand Ambassador specifically to help manage the Chinese reaction to any revelations about New Zealand's role in the surveillance. McKinnon speaks Chinese and was seen as most able to manage relationships with the Chinese leaders.
The Chinese Government reacted unhappily to an earlier Herald story that named China as one of about 20 countries targeted by the GCSB. That story contained no detail about China spying, just the word "China" on a list. Chinese foreign ministry spokesperson Hong Lei still responded that "China is concerned about relevant report".
China is known to be a major perpetrator of espionage on the global stage, and the US Government has repeatedly accused it of hacking into American computer networks.
Last year, China was linked to a hacking attack on a powerful New Zealand supercomputer operated by Niwa, used to conduct weather and climate research.
But the Snowden documents have shown countries in the so-called "Five Eyes" surveillance alliance - which includes New Zealand, the US, the UK, Canada, and Australia - are just as heavily involved in cyber spying and hacking.
China intelligence is handled inside the GCSB by a section of the agency that focuses on economic analysis.
According to GCSB staff, the economic section, known as the "IBE", specialised in Japanese diplomatic communications from 1981 until the late 2000s. In recent years its focus has shifted to intercepted Chinese communications.
• Nicky Hager is a New Zealand-based investigative journalist. Ryan Gallagher is a Scottish journalist who works for US news organisation The Intercept.
Kiwi-China relationship in jeopardy
A plot to spy on China is the most damning revelation from the Snowden documents - and Green co-leader Russel Norman says it is putting one of our biggest export markets at risk.
The Chinese government would be unhappy at the GCSB's attempt to access its communications, said Norman. "And for what? And because it can only have happened with the personal approval of John Key, it jeopardises the personal relationship between Key and [Chinese Premier] Xi."
Labour leader Andrew Little said New Zealand appeared to be speaking of its strong relationship with China at the same time as planning intrusive surveillance. He said the approaches appeared in conflict with each other.
The Snowden documents have emerged in a reporting project between the Herald on Sunday, investigative journalist Nicky Hager and the US news site, The Intercept.
Thomas Beagle, Council for Civil Liberties chairman, said the leak of the documents was an important democratic step to allow a level of involvement by the people being governed. "We need to know these things because we can't practice our diplomatic oversight without it. If we don't know these things are happening it's out of the realm of democracy."
He said other countries used a panel of trusted citizens as the oversight mechanism for intelligence agencies.
Victoria University's Dr Jim Rolfe, director of its Centre for Security Studies, said there were areas of government which were not helped by public scrutiny.
He said the Snowden revelations had produced benefits in revealing over-reach in some intelligence operations, although "90 per cent of it is prurient".
"I suspect things have been hurt rather than helped by Snowden because it has distracted policy makers from their work."