I just learned about this in researching Rehaif v. U.S., the new Supreme Court guns/illegal aliens/mens rea case, so I thought I'd pass it along. This is especially important, I think, if you tend to take classmates, coworkers, or other acquaintances to shooting ranges (as I've done myself).
[1.] Federal law, 18 U.S.C. § 922(g), bans gun and ammunition possession not just by felons, illegal aliens, illegal drug users, and the like, but also by aliens who have been perfectly legally "admitted to the United States under a nonimmigrant visa."
[2.] "Possess[ing]" and "receiv[ing]" has been viewed as including temporary rental of a gun at a shooting range; indeed, that was one of the bases for prosecution in Rehaif. Rehaif was illegally present, but the statutory definition of possession and receipt would apply equally to all the categories of forbidden possessors and recipients, including people legally admitted under a nonimmigrant visa. Likewise, see U.S. v. Moussaoui (11th Cir. 2010), in which the defendant was indeed a legal visitor prosecuted for possession at a shooting range.
[3.] But who is covered as having been admitted under a "nonimmigrant visa"? According to the Bureau of Alcohol, Tobacco, Firearms, and Explosives,
Generally, "nonimmigrant aliens" are tourists, students, business travelers, and temporary workers who enter the U.S. for fixed periods of time; they are lawfully admitted aliens who are not lawful permanent residents. In order to meet the definition of a nonimmigrant alien, the individual MUST hold a nonimmigrant visa. The definition does NOT include permanent resident aliens, aliens legally admitted to the U.S. with a visa other than a nonimmigrant visa, or aliens legally admitted to the U.S. without a visa.
So people who are on short-term trips from a Visa Waiver Program country (most European, East Asian, and Pacific democracies, plus Brunei and Chile), or countries as to which we have similar visa-free entry rules (Canada and Bermuda, I think), are not forbidden by federal law from renting a gun at a shooting range, or even buying or borrowing a gun to keep at their temporary home. But if they're tourists or short-term business visitors from, say, China or India or Israel or Mexico or Brazil -- trips for which a visa is required -- then they are so forbidden; likewise if they're here for an extended stay as a student or a business traveler.
[4.] What's more, if you take someone to a range knowing that they are, say, a U.K. citizen here on a student visa, or an Indian citizen here for a short trip, you are yourself likely committing the crime of aiding and abetting that person's illegal gun possession, or of conspiring with that person to illegally possess a gun. And that's so even if you don't know the conduct is illegal, so long as you know about the person's immigration status.
Likewise, a range employee who rents a gun and sells ammunition to a visitor knowing that the visitor is an alien here on a nonimmigrant visa -- for instance, because a tour guide or a friend of the visitor mentions that the visitor is just briefly visiting from China, or some such -- is also guilty as an aider and abettor or a coconspirator.
That's so even if the employee isn't 100% sure that the visitor is here on a nonimmigrant visa; under the "ostrich doctrine," a jury can be instructed that it "may find that a defendant acted knowingly if you find beyond a reasonable doubt that the defendant ... was aware of a high probability that [a particular fact was true], and ... deliberately avoided learning the truth." At least some courts hold that "failure to investigate" when one has knowledge of a high probability of an incriminating fact "can be a deliberate action." And it's also possible that the range employee might be guilty under 18 U.S.C. § 922(d) even if he just has reason to know of the visitor's immigrant visa status, though that's complicated (see the Rental of Firearm On-Premises section of this ATF publication). I expect that the typical range employee is safe because he has little reason to know the visa status of a foreign visitor; but an employee who knows that a visitor is a Chinese tourists and that most Chinese tourists come in on a tourist visa might well be guilty.
[5.] There are, though, some exception to the nonimmigrant alien possession ban, in subsection (y)(2) of the statute; they are chiefly for certain foreign officials, for aliens "admitted to the United States for lawful hunting or sporting purposes," or for aliens who are "in possession of a hunting license or permit lawfully issued in the United States."
So if the alien gets a hunting license, from any state (not just the one he's in), he's exempt from the ban until the license expires. That's apparently true regardless of whether he goes hunting, or plans to go hunting, or shoots with the gun with which he will hunt, or buys a gun with which he will hunt.
Some states (for instance, Alaska and Arizona) appear to let you order such licenses entirely online, and at a relatively modest cost (it seems to be $20 for a short-term Arizona license and a $60 for a longer small-game Alaska license, though I'm not positive). There's always some danger, to be sure, when one uses this sort of formalistic workaround that seems pretty clearly nonresponsive to the "spirit of the law," whatever that might be; it's possible that a prosecutor will think it's too clever by half, and that a court will agree. But as I read the letter of the law, buying this sort of cheap out-of-state license online should indeed be sufficient to exempt the buyer from the ban on possession and receipt by immigrant-visa visitors. (It wouldn't do anything for people who are forbidden to possess guns because they are felons, illegal aliens, and the like, since the hunting license exception doesn't apply to them.)
[* * *]
Naturally, this is just a general perspective; there may be extra complexities stemming from state laws and from other matters. But this should give you a sense of what's potentially dangerous (even if not of what's 100% safe) -- and a sense of just how odd gun laws can be.
UPDATE: I originally gave a Canadian on a student visa as an example, but it seems that Canadians (and Bermudans) don't need student visas to study in the U.S.; thanks to reader JeffDG for alerting me to this. I changed the example to U.K. citizens, and it could equally work for citizens of many other countries as well.