It’s called a straw purchase—a fairly common practice. Illegal, but easy to do and difficult to prevent. If you want sensible gun control, that’s where law enforcement needs to crack down.
Yeah, that’s how the Muslim couple in San Bernardino got their weapons they used, some friend of his who was a citizen bought them for him. That guy was sent to jail if I remember right.