It's true that this used to be a constant problem, but it's much less common these days because it's hard to disguise the use of medication with modern drug testing.
That said, I would be veeery careful before I bought an OTTB. Even though they're incredibly cheap ($1500-5000 at the track), sometimes just the fact that they were backed as long yearlings and raced at two messes up their backs and legs so badly that the vet bills make them not worth what you save with a cheap price.
Have you ever seen the two-year-olds with pin firing marks? I hated seeing that. That means (in case anyone doesn't know) that the horse bucked his shins. If you push a baby too hard, they can do that, and the old time trainers would pin fire them instead of giving them much needed time to rest.
He was sound as a dollar from the time my trainer picked him up until he was eventually turned out to pasture at age 22, and cossetted by two teenage twin girls until the day of his death. I showed him and he did very well. A tall, skinny chestnut T'bred with a Roman nose and an attitude. He tended to loaf around, but if you lifted the reins on him he still had a breathtaking turn of speed for 100 yards or so. And he could do his everies, so he was one hundred percent sound.