Fungal spores can easily be inoculated on substrate that we feed scarab beetle larvae. Unless substrate is being kept indoor in an airtight environment, it is not easy to perfectly prevent pest infection including fungal spores.
What is so bad about having fungal infection?
The substrate you feed scarab beetle larvae has a huge number of microorganisms good for larval development. You may think your scarabs are just feeding on wood chunk itself, but that is not quite right. They wouldn't eat alive tree, but only be collected from dead, fallen (sometimes standing) rotten trees having microorganisms breaking (trees) down. Fungal infection cannot be good when inoculated on your substrate (especially when you see the fruiting part, the mushroom) because the fungal culture ALSO feed on the microorganisms in substrate. If not treated properly in time, you are just wasting your substrate, and the scarab larvae has to compete with fungal culture.
*This container has been left like this only because the larvae has already pupated, and stopped feeding.
How to properly treat it?
The best and the optimal timing to treat it is when it first appeared. There can be many different ways to fight the fungal infection. One easy way is to completely dry the substrate out. Have it exposed to sunlight, and let it dried completely. fungal cultures are very weak to low humidity. Another way is to spray a diluted alcohol on the fungal culture to disinfect it. Try keep your substrate indoor, and in a breathable but filtered storage containers.