Yes, spoiled cake can give you food poisoning. Even when stored correctly, cake will go bad eventually. Refrigerating or freezing it will slow down the bacteria and mold growth but there's no way to stop it completely.