Ok, so I can’t tell you exactly what the worms are and how serious the situation is but it sounds like your little shell might have a parasite problem that came out in some poo and then spread through the substrate. I’d first get him out of there. Definitely dump the substrate and start fresh. Then I’d make an appointment with a vet asap. If they are in the substrate its likely they are living in his belly and he needs to be dewormed. Did you get him from a pet store? this happens pretty often (having worms/other parasites) in wild caught tortoises that are sold as captive bread.
Hopefully the vet can give him some worming meds (generally happen in 2 cycles.. one then another in a few months) and take care of the problem. If its getting to the point its infesting the substrate its either getting really bad or they are unrelated worms that came from a plant or something else in the environment.
I’d say not at all worth risking. I’m not sure where you are but an exotics vet can help you out and it won’t cost too much. If you can put some of the substrate with worms in a sandwich bag to bring with you and some poo as well that will make the diagnostic process go faster.
Once you start over, I’d suggest pouring boiling water on the substrate once a week or so when your tortie is able to be elsewhere. It’ll kill anything that lives in there and keep a good moisture level.
I hope this helps and please let us know how he is and what the vet says. If you need a vet suggestion let me know and Ill ask around (send me another ask!) Hang in there! *hugs* to you and your tortie.
(I hope this is coherent. Zoya and I just got home from the airport after a really long day of traveling so the brain is a little slow for me … Zoya is already dug down and sleeping.. gotta maintain the beauty rest).