Two men convicted of grooming and abusing girls showed "remarkable stupidity" by trying to smuggle drugs into prison during their trial.
Naveed Akhtar hid a parcel of mini mobile phones and opioid tablets in a Bradford Crown Court toilet for Fahim Iqbal to pick up and take to HMP Leeds.
The court heard a dock officer found the package in a toilet roll dispenser.
Iqbal, 28, and Akhtar, 44, were both sentenced to a further five months in prison.
Iqbal, of no fixed address, is serving seven years for aiding and abetting rape and Akhtar, of Newport Place, Bradford, 17 years for rape following a trial in February.
The drugs hearing was told the grooming trial was temporarily halted on 4 February for police to investigate two packages containing cannabis, opioid tablets and miniature mobile phones.
The second package was found under a chair in the dock.
Akhtar, who was on bail at the time, asked to go to the toilet during the trial and Iqbal, a serving prisoner, asked to go after him - resulting in a suspicious dock officer carrying out a search.
Andrew Dallas, defending Iqbal, said it was "widely known" on a HMP Leeds prison wing that Iqbal was being transported to court every day and he had been promised cannabis in return for carrying out the drugs plot.
Sentencing at the same court, Judge Jonathan Durham Hall QC told the pair they had executed the plan "with remarkable stupidity, and quite possibly some degree of pressure, under the noses of dock officers and myself".
"How on earth you thought you could get this into [HMP Leeds] I do not know," he said.
"It was an irritating, vexing and seriously stupid matter and, as counsel has said, it was doomed to failure."
The pair previously admitted two counts of drugs offences and a single count relating to their attempt to smuggle mobile phones.