In my addition, it is indeed in parsha 8. And if you actually bother reading to the end of the midrash, you will see that Rav Huna apparently disagrees. The larger point of the midrash seems to be that when people sin in private, the fruits of that become public. I might suggest that it would be much more beneficial to think about that idea rather than to worry about how Hashem punishes mamzerim.