Does she do it on a lunge line? I'm honestly a big believer in getting it on the ground first. That way you're not in the same danger as you are on her back. If it's only under saddle and not caused by anything physical try "taking away her engine" by making a small circle and disengaging the hind end a little, then ask her to go out of it at your pace
If you know it's a training issue not a health issue you can try turning her in a circle till she calms down. Make the circle big enough for her to stay cantering but small enough that she has to slow down.
It could be a discomfort issue, it is very hard to say without seeing the horse move. You could try to have her adjusted by a chiropractor to first rule that out, then if it is still there you could consult your veterinarian to see if it is something else like teeth that have been causing it.