Generally speaking, halakha does not allow a person to incriminate themselves.
Based on this rule Rav Yosef teaches that if someone makes a statement that will incriminate him the court will reject the statement in its entirety.
The opinion is presented in the name of Rava that adam karov etzel atzmo, ve-ein adam masim atzmo rasha – literally, “a person is his own relative, and a person cannot render himself wicked” – just as a person cannot testify against a close relative in beit din similarly he cannot testify against himself, incriminating himself. Nevertheless, as the continuation of the Gemara concludes, there exists an often discussed Talmudic idea – palginan diburei – that we split up his statement between what he says about himself, which we do not accept, and what he says about others, which we accept as testimony. For example, if a person says “I killed someone” we reject his self-incriminating statement, but we accept his testimony that the man had actually been killed.
The mechanism behind the concept of palginan diburei is subject to a disagreement among the rishonim. The Rashba argues that we can only apply it in cases where we can interpret the testimony in a way that will allow his entire statement to be understood as being truthful. For example, in the case mentioned above, we could say that the witness who says “I killed him” actually means “I killed him…accidentally.” If it is impossible to interpret his testimony in such a way, we would not apply the principle of palginan diburei, and we would reject his testimony entirely. Others, however, explain that the concept of palginan diburei is powerful enough to allow us to accept the conclusion of his testimony (that the man is dead) even as we reject the incriminating aspect of it (that the witness murdered him).
It should be noted that the rule ein adam masim atzmo rasha applies only in cases of criminal acts that would lead to punishments such as lashes or a death penalty. If someone admits to owing money then the court will view his confession as equivalent to testimony made by witnesses, and obligate him to pay.