jailhouse lawyer

noun

:a prison inmate self-taught in the law who tries to gain release through legal maneuvers or who advises fellow inmates on their legal problems