Speaking at the Cheltenham Science festival, the intelligence chief warned that nation states were currently developing the kind of cyber programmes that could attack the UK, but that terrorist groups were also looking to take advantage of the technology.

“At some stage they will get the capability,” he said.

“There are certainly states and groups with the intent to do it, terrorist groups, for example, who have no threshold when it comes to the loss of life.

“We’re not quite there yet, but as the world becomes ever more connected that will become a greater risk.”

Speaking as the controversial Investigatory Powers Bill passed its third reading in the House of Commons, Mr Hannigan also defended the surveillance of internet activity by the intelligence services, saying seven attacks against the UK had been foiled in the last 18 months due to bulk data analysis.