1456. Confession to a priest is an essential part of the sacrament of Penance: 'All mortal sins of which penitents after a diligent self-examination are conscious must be recounted by them in confession, even if they are most secret and have been committed against the last two precepts of the Decalogue; for these sins sometimes wound the soul more grievously and are more dangerous than those which are committed openly.'
....
1467. Given the delicacy and greatness of this ministry and the respect due to persons, the Church declares that every priest who hears confessions is bound under very severe penalties to keep absolute secrecy regarding the sins that his penitents have confessed to him. He can make no use of knowledge that confession gives him about penitents' lives. This secret, which admits of no exceptions, is called the 'sacramental seal,' because what the penitent has made known to the priest remains 'sealed' by the sacrament."
******************
Canon 983 §1 The sacramental seal is inviolable. Accordingly, it is absolutely wrong for a confessor in any way to betray the penitent, for any reason whatsoever, whether by word or in any other fashion.
Can. 984 §1 The confessor is wholly forbidden to use knowledge acquired in confession to the detriment of the penitent, even when all danger of disclosure is excluded.