Lawyers for MI5, MI6 and GCHQ faced challenges brought by nearly a dozen British and international civil liberties groups over the legality of US and UK digital surveillance programmes, including Tempora, Prism and Upstream.