Not a problem if you like maggots
I've had them in my compost many times. They do gross me out when there are enough of them. And it always looks moldy. Doesn't bother me, but my compost is pretty far from my house, in the back of the yard, so less likely to draw critters close to the house. I've found small snakes in my compost, and mice.... Prevention can also include hardware cloth on the bottom of a bin to keep critters from entering from underground tunneling.
The only food I compost is fruit/veggie scraps and coffee grounds. My compost is made of mostly yard scraps.
Karen