One question is, whether Canon Law punishes those who receive sacraments from heretics or otherwise illegit clerus.
Another question is, whether graces flow.
Here some quotes concerning the 2nd question.
The Church is clear on this.
.
If you willingly receive sacraments from a known heretic or illegitimate cleric, you commit the same mortal sin as the cleric administering the sacrament, and no grace flows where mortal sin occurs.
.
If you receive sacraments from illegitimate or heretical clerics in ignorance of their status, you commit no mortal sin but no grace flows either because the cleric commits mortal sin in administering such. No grace flows where mortal sin occurs.
.
This is why it is so important to make sure your cleric is legitimate and that he does not teach heresy.
.
Fr. Pfeiffer has yet to provide indisputable proof of his conditional consecration and legitimacy of his lineage. My sister heard Fr. Pfeiffer teach heresy. She questioned him on it and he stood firm on the teaching. She verified with several bishops, including +Williamsom, informed Fr. Pfeiffer, and he still stood firm on his teaching. Fr. Pfeiffer, in my mind, is a heretic.
.
In this crisis of the Church, no cleric should refuse to provide proof of his lineage. If he does refuse, run away from him.