Consider reading My Country Versus Me by former Los Alamos nuclear physicist Wen Ho Lee. Long story short, he was an American nuclear scientist, born in Taiwan, who was accused of giving the schematics of the W-88 warhead to the People's Republic of China. He had done no such thing; but he nevertheless was forced to plead guilty to one felony count of mishandling classified information (as he has once worked from home while under a tight deadline) and released for time served. The federal judge presiding over the case actually apologized to him during sentencing due to the cruel conditions of his solitary confinement in custody, and the stress it imposed on his family.
The way this pertains to your question is that, believe it or not, a suspected terrorist or nuclear spy does, in fact, have a right to have access to classified information in mounting a legal defense. Not him, personally, of course, but his legal counsel has the authority to request any documentation that might be pertinent. Because of the sensitivity of the information, the counsel has the legal responsibility to withhold the classified information they receive from their own client. How that could possibly be enforced, I have no idea, as attorney-client conversations are privileged; but a scrupulous attorney is bound by his/her professional ethics to use classified data to defend the client, while at the same time withholding that data from the client.
Not for nothing, the government had to construct a sound-proofed conference room in the courthouse, for Lee and his lawyers. Not so that Lee's lawyers could divulge classified data to suspected nuclear terrorist Lee, but so that Lee could safely and lawfully discuss nuclear weapons with his lawyers. He was lucky enough to have pro bono representation from a very elite legal team; the same team that had represented Oliver North, if memory serves.
Given the strange and delicate balancing act of protecting the suspect's due process, and protecting sensitive state secrets from that very same suspect... that is why security hawks in the U.S. oppose trying terrorist suspects in civilian criminal court proceedings (see Lindsay Graham: "you don't get a lawyer!). That delicate balancing act requires society to place a great deal of trust in the suspect's legal counsel. Not so difficult when the lawyers in question is a respected, prestigious firm with experience in national security issues, but could be a bit more controversial if the court-appointed lawyers were, say, native Arabic speakers with a little bit too much, culturally, in common with the defendant for the folks watching the 6-o-clock news to be comfortable with.