A serial sex offender was given the opportunity to commit violent rapes on fellow inmates after the Corrections Department deleted a warning saying he was not to be double-bunked.
Two of the three men who told police they were raped by William Katipa, 52, have been paid compensation by Corrections.
There is yet to be a settlement with the third person.
The actual number of victims may be much higher, with documents showing Katipa shared a cell with as many as 50 other people before the rapes emerged.
For the prison rapes, Katipa was sentenced this year on five counts of sexual violation, four of indecent assault, three of threatening to kill, a charge of attempted sexual violation and a charge of assault with intent to injure.
INSIDE OUR PRISONS
• Prison suicides surge during the inmate boom
• Andrew Little: 'Tough on crime doesn't work and it has to stop'
• Justice path and bulging prisons - will NZ listen to scientist or sceptic?
• 'Best guess' on prison numbers before inmate blowout
Katipa was already serving a sentence of preventive detention after being found guilty of raping two other people.
He had been sent to prison 2002 for twice raping a 13-year-old girl. While behind bars, DNA testing revealed he was the man who raped a 19-year-old woman in 1994 while her daughter, 2, was present.
Justice Matthew Downs told Katipa he was "unremorseful" and "dangerous", delivering a second sentence of preventive detention of which he must serve a minimum of 15 years in prison before being able to ask for parole. Katipa has since appealed.
Corrections told the Herald it made mistakes which allowed Katipa access to the two men he raped in 2015.
At that stage, it already had a record of a complaint made by a cellmate of Katipa's in 2006 and in 2009 placed an alert on his file saying "NTDB" - Not To Double Bunk.
Chief Custodial Officer Neil Beales said: "This alert was deactivated by a Corrections officer in August 2014.
"Despite extensive investigation, prison management have not been able to determine the reason for the alert being deactivated. We acknowledge the alert should not have been deactivated."
Beales said Katipa was not currently double-bunked and there was an "active alert" on the Corrections' computer system warning staff against placing him with other inmates.
"We have formally apologised to two of Mr Katipa's victims. We accept that Mr Katipa should not have been placed in a cell with them and a compensation settlement has been agreed with both of them. We are currently in consultation with the third victim's lawyer."
Beales said inmates who believed they had been assaulted by Katipa - or any other inmate - should feel encouraged to speak with police.
"We are not aware of any further complaints made against Mr Katipa to date."
There was a police inquiry into the 2006 allegation that Katipa had raped his cellmate.
Prison guards had noted the blocked peephole allowing access to the cell but missed the note his victim had slid under the cell door asking for help.
Police also recovered Katipa's semen from the man's boxer shorts and his DNA from his victim's neck and face.
No charges were laid and detective senior sergeant Daryl Smith would not comment ahead of Katipa's appeal, although said police worked hard to do best for victims of crime.
The charges were laid when the 2015 complaints came to light with the earlier complainant telling the court he was "angry the authorities were slow to respond to his complaints" and that he had not been believed.
Despite the complaint, Katipa remained in the pool of double-bunked prisoners through to 2009, when Corrections brought in a system which evaluated whether inmates should be sharing cells with others.
The Shared Accommodation Cell Risk Assessment (Sacra) tool made recommendations by drawing on a prisoner's age, security classification, offending history, history of imprisonment, gang affiliation, "physical characteristics", mental health and other special needs.
As a result, a note was made on Katipa's file expressly banning him from being housed with other inmates.
The warning was inexplicably removed in 2014 and Katipa was again housed with other inmates.
The other two complainants in the case were bunked with Katipa the following year - both trapped with him overnight to face prolonged assaults from which there was no escape.
Documents sourced by the Herald have revealed the chilling story of Katipa's reign of terror against fellow inmates.
The first attack for which Katipa, then 40, was convicted is said to have taken place in Waikeria Prison in 2006.
Katipa, then 40, was locked in a cell with a fellow inmate, 27, who was serving time after convictions for a range of property offences.
The pair exchanged stories of sexual abuse each had suffered as children before, according to documents, Katipa told his cellmate to join him on the bottom bunk.
The cellmate was told that if he did not then Katipa would kill him, documents show.
He also blocked the cell peephole used by guards and turned the radio up to block the sound of what came next.
Sentencing notes showed Katipa forced his cellmate to carry out sex acts on him.
"He was terrified," said Justice Downs.
Later that night, Katipa ordered the cellmate back to the bottom bunk. On this occasion, Katipa raped the cellmate.
During the course of the rape, a prison guard asked through the door why the peephole was blocked and told the men inside to clear the view.
Katipa did so, and it was during this time the cellmate slipped a note under the door asking for help.
No help came, and later that night - according to the police case - the sexual assault resumed.
Again a prison guard asked why the peephole was blocked - and documents show Katipa continued the rape while telling the guard he was on the toilet.
The cellmate was warned the next morning he would be killed if he told anyone what had happened.
Even so, the sentencing notes stated: "(The cellmate) made a prompt complaint after sobbing uncontrollably to a prison officer."
It was then police recovered semen from the victims boxer shorts and DNA from there, and the victim's face and neck.
No charges were laid. A year after release, the victim - with no prior sexual violence convictions - raped a woman, was convicted for the attack and returned to prison.
Corrections' understanding of the risk Katipa posed emerged in 2009 when it introduced the Sacra tool.
It came as the new National government revealed plans to extend double-bunking throughout the prison system.
Then-Corrections minister Judith Collins cited a "prison crisis" as inmate numbers reached 6500, blamed the former Labour government for not accounting for the growth in inmates numbers and used it to justify double-bunking.
Nine years later the prison population sits above 10,000 with many prisons close to 100 per cent occupancy. About a third of New Zealand cells are now double-bunked.
The new Sacra tool red-flagged Katipa as too risky to be placed with others - until the alert was removed in 2014.
In September 2015, Katipa was bunked with an inmate at the Auckland South Correctional Facility who would later tell police of being raped through the night.
By now, Katipa was 49. His new cellmate was 24, in prison for a violent dairy robbery.
They were locked into their cell for the evening, during which Katipa told his cellmate to perform a sex act on him.
When he refused, the court was told Katipa became violent and beat the young man unconscious - at which point he raped him.
The victim awoke during the rape and attempted to resist, eventually breaking free. He testified that Katipa beat him as he sought the safety of the top bunk.
The next day, he asked to move out of the cell, keeping his silence until months later when detectives began investigating and only when he was moved to a different part of the prison.
Katipa was convicted of a third rape in prison, said to have occurred in November 2016.
The last complainant was 19, in prison for aggravated robbery and possession of a knife.
Again, Katipa waited until his victim was locked in with him for the night. Late in the evening, he covered the peephole with a towel and blocked access to the emergency button.
He demanded the young man get into his bunk bed naked, said force would be used if he didn't comply and then forced him to carry out sex acts.
When the 19-year-old sought out a prison officer, asking to change cells, Katipa witnessed the approach.
That evening, back in the cell, he threatened his victim with a knife. Evidence during the trial quoted Katipa telling the young man he was "already doing life" so could kill him "if he wanted to".
The young man was transferred to a different cell the following day, told his cellmate what had happened and then reported Katipa's attacks to police.
Detectives tracked down and interviewed Katipa's cellmates and, in addition to the teenager, received complaints from two other men. He had been bunked with 50 others during his time in prison.
University of Canterbury criminologist Professor Greg Newbold said inmates were unlikely to disclose prison rapes.
He said there was a broad prohibition on "narking" or "grassing" which extended to assaults and sexual violence.
Katipa defended the case against him by highlighting the criminal records of the victims, saying dishonesty was a "way of life".
Downs said "your trial provides an obvious example of why victims can be reluctant to complain about sexual offences". The process could be "traumatic" and "harrowing", he said.
The assault by Katipa came after the conviction of Stephen Mark Gotty, 57, who sexually assaulted a 19-year-old while double-bunked in Mt Eden prison. Gotty received a sentence of preventive detention with a minimum nine years in prison.
The incidents led to a review of the double-bunking policy throughout the prison system.
The review found Katipa's attacks were not as a result of problems with the double-bunking system but "staff performance failure".
Beales said the review of the Sacra system found the tool was working - but it wasn't being used with consistency across the prison network.
The report into use of the Sacra system, released through the Official Information Act, showed Corrections staff didn't understand how it was meant to be used and would sometimes place inmates in cells with other - then do an assessment to see if they should be housed with someone else.
About three-quarters of the assessments were done on time, the report showed.
The assessments were also delayed if there were staff shortage and in other cases, Corrections officers talked inmates into being double-bunked.
Corrections staff also showed confusion over the NTDB (Not To Double Bunk) warning, with the review stating they were unsure who was meant to be placing the warning on the system or even when they were obliged to do so.
There was also risk attached to the 68 different types of alerts with no guidelines for reference and confused staff as a result.
The review led to greater training, better documentation and allowing only senior Corrections officers to remove alerts and to check alerts were accurate when prisoners were moved.
Minister of Corrections Kelvin Davis said he stood by comments in Opposition that sex offenders should not be double-bunked with other inmates.
"All prisoners are assessed on a range of factors for their suitability to share a cell, and no one who poses a high risk to others, no matter what their history of offending, should be double-bunked."
Davis said he didn't want any prisoner doubled-bunked but pressures on the prison network meant it needed to be done.
He had pledged to reduce the prison population by 30 per cent in 15 years.
"As our plan to reduce the prison population eventually begins to take effect, we won't need to double-bunk anymore."