Simple cake batter with no perishable filling. For example, chocolate cake with buttercream filling. How do you know if a cake is "bad"? Does it actually spoil or mold? Or does it just get dry and lose flavor?
It usually dries out first, but yes depending on the environment it can mold.
If it's completely covered in buttercream, the air can't get to it to dry it out. It maintains the moisture, thereby causing it to eventually mold, which usually takes two weeks.