I'm pretty certain it's illegal to hire a foreign national to contribute in any way to a candidate's campaign.
There are exceptions regarding foreign nationals if they volunteer; but even then, there are strict guidelines to what capacity they can participate to ensure they don't cross the line into contributing.
Foreign nationals - FEC.gov
Volunteer activity
Generally, an individual (including a foreign national) may volunteer personal services to a federal candidate or federal political committee without making a contribution. The Act provides this volunteer "exemption" as long as the individual performing the service is not compensated by anyone. The Commission has addressed applicability of this exemption to several situations involving volunteer activity by a foreign national, as explained below.
The salient terms in all this are "contribution", and "influence". Foreigners cannot contribute, and cannot control or have significant influence over a campaign.
However:
Experts told me that when it comes to campaign finance law, hiring or contracting a foreigner to do services for a campaign is allowed. “You can pay a foreign national to provide you with services, so a campaign, for instance, could have a campaign attorney who is a Canadian citizen,” Levinson said. “As long as you pay fair market rates for those services, that’s not what the federal campaign act says is prohibited. That’s just a fair exchange of money for services.”
If this kind of seems like a loophole, experts pointed out that it would be really hard to run a campaign otherwise. It would mean having to worry if the campaign signs you printed came from a foreign company, or if the catering firm you hired had foreign workers.
If a campaign is paying someone for work or services, they’re being compensated. But where that doesn’t happen, and a campaign is accepting a contribution — or “thing of value” — from a foreign government, the question then is what’s in it for them?
It would be too funny if hiring Steele directly would be prohibited, but involving a middleman would make it all hunky-dory. That would be too obvious a loophole making the whole regulation perfectly toothless. Anyway, hiring a contractor at fair market rates is not a contribution, and as long as this subcontractor has no influence over what's done with the material, there is no campaign finance law violation - as far as I can discern. Of course, you'll probably find folks arguing the opposite, and most assuredly you can find Trumpletons screeching "foul."
Whatever, Trump's solicitation of dirt in his call to Zelensky is as clear a violation as it gets, and it is perfectly ludicrous that the sycophants at DoJ strained to find there was no violation because they couldn't determine the value of the solicited dirt. What a crock...