You're correct that it's legal if in fact it was the Cruz campaign that did it. But if it's a "false flag" operation trying to embarrass Cruz, that's different. The voting records are easy to get in my state (Colorado).
Funny how this is making a big splash, but when Obama did it, the press wouldn’t touch it. No outrage.
That said, what a massive mistake.