@FSWer There's generally no specific rule. The federation, broadcast station, or competition gives the commentators an info sheet about each of the competitors to read off of. This generally has the ISU bio and some "fluff piece" information (ie. they have a dog, they started skating at age 3, they are also in college). I believe some stations also gives the commentators a planned program content sheet for each competitor. They're definitely allowed to say stuff like that - information that is released for them to relay to the public.
Other information is gleaned from the commentators own research. This might be interviews and press conferences, casual conversations with skaters and coaches, watching practice sessions, and doing some googling of their own. I'd imagine all the stuff from interviews/press conferences and practice sessions is fair game, as these are known to be public. Some of the things said in casual conversations is meant to be shared, and other stuff should be kept private (and I'm sure the skater/coach will tell them what's private); whether the commentator shares only what should be shared is an individual judgement.
I would imagine Ashley was fine with Tara and Johnny knowing she was hurt. She doesn't generally make a huge deal out of injuries or say anything about , them, but in this case statements were prepared. Skaters are required to report all injuries and illnesses to USFS, and a team doctor is present at international competitions, so I'm sure USFS was aware of the issue well in advance. It does seem like she told them, or at least wasn't thinking it would be a secret, as they were aware of the ankle wrap and that there was an ankle injury of some sort. In fact, I think the ankle issue was reported before competition started.