It is not illegal: there is NO law against networking, direct contacts, or even nepotism.But it may be against company policy or practice: an employer is free to bar this and require all job candidates to go through HR, and is equally free to refuse to consider anyone who does not.