It's not illegal in the US in most cases, when it’s not related to copyright law. However, it is still considered a violation of ethics or honor codes. This can lead to some sort of disciplinary action which will depend on the rules of the institution or workplace.