I think it's only illegal by the Home Office if she doesn't have dual nationality. This appears the be the crux of the issue.
This excerpt from the Guardian puts across both sides of the argument quite succinctly
"Experts with knowledge of the British and Bangladeshi legal systems are divided on whether the Home Office’s action is legal. Fahad Ansari, a lawyer who acted for two men in a similar case,
has said the UK-born children of Bangladeshi parents are automatically dual citizens at birth, but that right lapses at the age of 21.
The government lost that case, but only because the two men were over 21, which would not apply to Begum, who is 19."
"But Najrul Khasru, a British-Bangladeshi barrister and part-time tribunal judge who has reviewed Bangladesh’s citizenship laws, told the Guardian he believed Begum was not a Bangladeshi citizen unless, at the time of her birth, her parents had
registered her at the High Commission, which he said was very uncommon within the British-Bangladeshi community."