Emergency legislation to stop convicted terrorists being released early could be introduced as soon as this week, a senior minister has told Sky News.
Michael Gove said the government wants to change the law "as early as possible" in the wake of the Streatham attack.
Sudesh Amman, 20, stabbed two people a week after being released halfway through his sentence for spreading extremist material.
Police have said the attack in south London on Sunday is believed to have been "Islamist-inspired".
Usman Khan, who killed two people in the London Bridge attack last year, was also released early.
Under the plans, terror prisoners – including ones currently in jail – would not be allowed out until they have served two thirds of their sentence and until the Parole Board has agreed.
The current maximum penalties for offenders will also be reviewed.
More from Streatham Terror Attack
Speaking to Kay [email protected], Mr Gove said the government wanted to work with opposition parties "in order to make sure that the laws are ready, that they're shipshape and that we can be absolutely certain that people who would otherwise be released early stay behind bars so the public are protected".
The Chancellor of the Duchy of Lancaster added that terrorist offenders should be locked up indefinitely "if necessary".
"We need to be able to prove that people are no longer a danger to the public," he said.
"If you have people who are in the grip of an ideology, that ideology means they want to kill innocent people in order to advance a particular religious and political view, they are a danger to society.
"Until we know that they are comprehensively de-radicalised and that it is safe to have those people on our streets then public protection must come first."
The prime minister's official spokesman would not comment on whether the government had identified any terrorists due for release before the new law is enacted.
"A particular issue has been identified where people have been released at the automatic half-way point and we have no powers to continue to hold them, which is why we are bringing forward emergency legislation at the earliest possible opportunity," they said.
But the UK's former reviewer of terror legislation has said the proposed law may be illegal.
Lord Carlile, who held the role from 2001 to 2011, has cast doubt on whether changes to the release conditions of those already sentenced could be applied retrospectively.
Speaking in the House of Lords, Lord Carlile suggested the plans might have gone too far and warned of a risk of legal challenge to their retrospective nature.
He instead urged the reintroduction of control orders.
Lord Carlile said they would be an "effective and proportionate response" to tackle the problem of offenders being automatically released after half their sentence.
Control orders were introduced under 2005 anti-terrorism legislation.
They put a suspect under close supervision and were described by some as similar to house arrest, with restrictions on who the suspect met and where they went.
They were replaced by measures known as TPIMS (Terrorism Prevention and Investigation Measures) in 2011, which the government said were less intrusive and addressed concerns about civil liberties.
Shadow attorney general Shami Chakrabarti told Sky News that she believed "it would be better that any early release were in the hands of the Parole Board and weren't automatic".
But she added that a tough stance from the government should not distract from the underlying issues.