Letting a bowl of flour and water go bad in a warm corner seems problematic at best.
I'm willing to believe there is some process that goes on to limit pathogens, but reading around this doesn't seem to even be considered.
Seasoned Advice is a question and answer site for professional and amateur chefs. It only takes a minute to sign up.Sign up to join this community
The hint is in the name, sourdough. Per the University of Wisconsin Extension:
Properly prepared starters are safe because they become acidic due to the fermentation action of lactic acid-forming bacteria present in the mixture. These bacteria and the acid environment formed inhibit the growth of other bacteria, but do allow yeast, if added, to grow and help leaven bread products.
Still, they point out care must be taken to get a good result. There have been food safety incidents related to home made starters, and using starters that can be stored in the refrigerator is recommended.
Please see the linked article for more detail.
There is a difference between letting something "go bad" and fermenting it. Fermenting is an intentional process by which certain (desirable) bacteria / fungi "eat" the food. The "waste" products of those microbes can be very valuable for humans, be it because it adds flavor, nutrients such as vitamins or because of other properties (such as the leavening of bread). Usually it's a combination of the above. If something spoils, however, the food is contaminated with undesired or even dangerous bacteria.
Sourdough in particular isn't that different from bread that's leavened with only yeast. Yeast is a fungus. The only difference is that sourdough also contains lactic acid bacteria (which are also in your intestines, the air and on most veggies. It's probably one of the most common bacteria there is). Those bacteria are the reason sourdough doesn't spoil easily, by the way.
For millennia, fermentation was one of the most important ways to preserve food (sauerkraut for instance) or bake bread (sourdough, Ancient Egyptian times). Even salami is fermented. Combined with refrigeration, such food can last even longer. Sauerkraut doesn't spoil for 6 months, easily.
Long story short: there are a great many microbes that are very important and beneficial to humans. Fermented food is as safe as any other food, given that it was fermented properly. As for sourdough: it maintains a very stable culture of lactic acid bacteria and yeast, effectively preserving the dough for as long as they don't die (and even then, the lactic acid slows the growth of pathogens considerably).
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?