As always, "ite ad Thomam" (go to Thomas) for the answer to another riddle: :D
Summa Theologiae: Part III, Question 64, Article 5:
Objection 1. It seems that the sacraments cannot be conferred by evil ministers. For the sacraments of the New Law are ordained for the purpose of cleansing from sin and for the bestowal of grace. Now evil men, being themselves unclean, cannot cleanse others from sin, according to Sirach 34:4: "Who [Vulgate: 'What'] can be made clean by the unclean?" Moreover, since they have not grace, it seems that they cannot give grace, for "no one gives what he has not." It seems, therefore, that the sacraments cannot be conferred by wicked men.
Objection 2. Further, all the power of the sacraments is derived from Christ, as stated above (3; 62, 5). But evil men are cut off from Christ: because they have not charity, by which the members are united to their Head, according to 1 John 4:16: "He that abideth in charity, abideth in God, and God in him." Therefore it seems that the sacraments cannot be conferred by evil men.
Objection 3. Further, if anything is wanting that is required for the sacraments, the sacrament is invalid; for instance, if the required matter or form be wanting. But the minister required for a sacrament is one who is without the stain of sin, according to Leviticus 21:17-18: "Whosoever of thy seed throughout their families, hath a blemish, he shall not offer bread to his God, neither shall he approach to minister to Him." Therefore it seems that if the minister be wicked, the sacrament has no effect.
On the contrary, Augustine says on John 1:33: "He upon Whom thou shalt see the Spirit," etc. (Tract. v in Joan.), that "John did not know that our Lord, having the authority of baptizing, would keep it to Himself, but that the ministry would certainly pass to both good and evil men . . . What is a bad minister to thee, where the Lord is good?"
I answer that, the ministers of the Church work instrumentally in the sacraments, because, in a way, a minister is of the nature of an instrument. But an instrument acts not by reason of its own form, but by the power of the one who moves it. Consequently, whatever form or power an instrument has in addition to that which it has as an instrument, is accidental to it: for instance, that a physician's body, which is the instrument of his soul, wherein is his medical art, be healthy or sickly; or that a pipe, through which water passes, be of silver or lead. Therefore the ministers of the Church can confer the sacraments, though they be wicked.
Reply to Objection 1. The ministers of the Church do not by their own power cleanse from sin those who approach the sacraments, nor do they confer grace on them: it is Christ Who does this by His own power while He employs them as instruments. Consequently, those who approach the sacraments receive an effect whereby they are enlikened not to the ministers but to Christ.
Reply to Objection 2. Christ's members are united to their Head by charity, so that they may receive life from Him; for as it is written (1 John 3:14): "He that loveth not abideth in death." Now it is possible for a man to work with a lifeless instrument, and separated from him as to bodily union, provided it be united to him by some sort of motion: for a workman works in one way with his hand, in another with his axe. Consequently, it is thus that Christ works in the sacraments, both by wicked men as lifeless instruments, and by good men as living instruments.
Reply to Objection 3. A thing is required in a sacrament in two ways. First, as being essential to it: and if this be wanting, the sacrament is invalid; for instance, if the due form or matter be wanting. Secondly, a thing is required for a sacrament, by reason of a certain fitness. And in this way good ministers are required for a sacrament.
St. Thomas shows that priests are used as instruments and actors, by God who is the AGENT effecting the sacraments.