The Home Office has argued it was justified in revoking Shamima Begum's citizenship even if she was trafficked to Syria and "brainwashed".
Sir James Eadie KC said the threat posed to national security was the most important factor in making the decions, not how a person came to pose that danger.
He told the Special Immigration Appeals Tribunal (SIAC): "You can be trafficked in the most ghastly, unacceptable way, exposed in the most unacceptable way, desensitised in the most unacceptable way and yet, unfortunately... still be a security threat.
"If they do pose such a danger, how they came to pose that danger is not important. What matters is that they do in fact pose such a danger.
"No one disputes that it is entirely possible for a person to have been trafficked or manipulated or brainwashed or similar and yet be the most serious danger to the public".
Ms Begum was 15 years old when she travelled from London, through Turkey, into territory controlled by the so-called Islamic State.
Now aged 23, she is challenging the decision to strip her citizenship on national security grounds after she was found, nine months pregnant, in a Syrian refugee camp in February 2019.
The SIAC heard that, according to the security services, people who travelled to Syria to align with IS "were likely to have been radicalised, to have contributed to the continuance of Isil as an entity and may have received military training, fought with Isil or taken part in terrorist attacks".
Ms Begum's lawyers said she was "recruited, transported, transferred, harboured and received in Syria for the purposes of sexual exploitation and marriage to an adult male".
Sir James previously said then-home secretary Sajid Javid was aware of Ms Begum's "age and circumstances of her travel to Syria" when he made the decision to deprive her of her British citizenship.
He said Ms Begum travelled to Syria "with her eyes open" about the brutality of IS.
"She travelled for the purpose of aligning with Isil and once in Syria she did align with Isil.
"The assessment is that she did that with her eyes open. The ideology of Isil and their uncompromising brutality had been widely covered in the media," he said.
Ms Begum's lawyers argued she was "persuaded" by friends and an "effective Isis propaganda machine".
On Wednesday, the tribunal heard that Ms Begum's mother's world "fell apart" after her daughter ran away from home.
The hearing in London, before Mr Justice Jay, is due to finish on Friday, with a decision expected in writing at a later date.