The officer, who had only recently completed training, was attacked during a routine cell check at HMP Littlehey in Cambridgeshire on Tuesday morning.
It is believed that at some point during the assault she lost consciousness or was knocked out.
Other inmates on the wing raised the alarm but the cell was blocked.
When staff eventually gained access they found the prisoner had taken off some of his clothes.
The female officer was treated for bruising by medical staff at Littlehey, which holds about 1,200 male sex offenders and rapists.
The man is not believed to have been formally arrested.
The Chair of the Independent Monitoring Board (IMB) for Littlehey, Harry Chandler, said: “As the IMB stated in its last report for the establishment, the Board considered Littlehey to be a generally safe environment for staff and prisoners. The recent incident was therefore unexpected.
“As it was a serious incident, the Board will be reporting on it and the prison’s management of the incident in due course.”
In 2016, there were 17 assaults on prison staff at Littlehey, the highest number for three years.