The government has been acting unlawfully by keeping prisoners in jail longer than necessary, judges say.
Some prisoners are staying in jail longer than necessary, judges ruled
The Appeal Court ruling came in a case brought by a sex offender who had been handed an indeterminate jail sentence.
Under the sentence offenders are given a minimum tariff, but must prove they are no longer a danger to the public before they can be released.
David Walker argued he cannot be considered for release because his jail does not offer a parole course.
The Court of Appeal ruled there "was a general and systemic legal failure".
The government was granted a stay on the ruling, pending an application for permission to make an appeal.
BBC home affairs correspondent Daniel Sandford said if the government's appeal was not successful, hundreds of prisoners might have to be released before it was determined that they were safe .
'Cannot be justified'
Walker was given an indeterminate sentence after being convicted of sexual assault while drunk, and is currently in prison in Doncaster.
He was given a minimum tariff which expires in October, but he cannot be considered for release until he has gone through the parole procedure, which includes going on a parole course.
But his lawyers say there are no parole courses for life prisoners at his category of jail. They claim he is therefore being subjected to arbitrary detention in breach of his human rights.
Lord Justice Laws, sitting with Mr Justice Mitting, said that keeping a prisoner in jail without assessment of the danger he poses could not be justified.
"It is therefore unlawful."
The judges declared that Justice Secretary Jack Straw has acted unlawfully by failing to give prisoners the chance to show they are no longer a danger to the public at the end of their minimum sentences.
A second man, Nicholas Wells, also challenged the Parole Board over its provisions for prisoners.
Wells's 12-month minimum term for attempted robbery expired last September.
The Parole Board did not review his case until eight months later, under pressure from the High Court, but declined to release him.
Offence-focused work had not been available at Wells's prison.
His risk to the public therefore had still to be assessed as high.
Meanwhile, the Prison Reform Trust says the sentences have stretched jails to breaking point.
It says more than 3,000 indeterminate sentences have been passed, many for relatively minor offences, in the past two years.
Juliet Lyon, director of the trust, said the sentences had been designed as a technical measure to detain a small number of dangerous offenders.
"But badly drafted, and whipped up by the previous prime minister and home secretary, they have become a ferocious, unjust law that, in two years, has catapulted around 3,000 people into jail for who knows how long."
Other people have also criticised indeterminate sentencing.
The government said a review of the sentencing was already under way.