Legal loophole allows foreigners to buy guns