It's understood that prison is and should be unpleasant. Still, that doesn't mean prisoners have no protections. The protections are more limited than for a free person, of course.
Still, in the case of an inmate attack, under some circumstances, there are claims that even the imprisoned can make. Let's take a look at vicarious liability for institutions of incarceration.