One of the core teachings of Buddhism is that, basically, you're the one kicking your ass. There is plenty of disagreement about how this self-ass-kicking actually works, and at this meetup we'll look at both the core insight and some of the diverse opinions.
Buddhism is fundamentally atheistic, and it also holds that "justice is done". Most people think justice can only be done if there is a judge; Buddhists replace a judging God with something like "natural laws". The universe is set up in such a way that intentions bring about results of a similar character. Harming intentions bring about harm, and the first one in line to suffer that harm is the intender. (This is why a properly constituted agent will, say, pity the person who is torturing them.)
If justice is done, to whom is it done? Again contrasting with familiar Western creeds, Buddhism denies that there is a unitary person to take on statuses like "guilty" or "innocent". Those natural laws of retribution operate not on persons so much as on streams of events that we customarily (and clumsily) call "persons". In fact, the thinking goes, the better you understand that there is no unitary person, the better you understand how and why the laws of retribution work.
The following is nothing like "required reading", but it might be of interest at introducing the classical debates: Vasubandhu's Karmasiddhiprakarana.