First, the good news: if your sourdough spoils, you can easily detect it with your senses. It cannot happen that your starter goes bad, that you accidentally continue to use it without realising it and cause yourself harm. Many harmful germs cannot even spread in sourdough because it is simply too acidic. If your sourdough goes bad, you can see it with your eyes.
There are two unwanted germs in particular that can spread in sourdough: Mould and yeast. You can find more about both in the respective article and on our culture channel.