Simple legislative solution? Impose a positive obligation on social media companies to verify that political advertising content purchases are being bought by legitimate domestic actors.

Punish non-compliance (and I'd include accepting purchases from fronts for foreign troll farms on a 'reasonably ought to have known' basis) with having their servers blocked in the affected countries for the next election cycle.

I think the credible threat of being entirely blocked from certain markets for four-ish years would motivate them to solve the foreign subversion problem in a big fast hurry.