Following existing law and applying reasonable expectations, I would point to the old adage "intent is 9/10ths of the law".
It would probably be legal to do this, as long as no one could reasonably show that you intentionally trained the LLM on said leaked source code with the intent to reproduce the product.
Of course, civil suits could be another matter entirely. If you pick a product to rip off that's owned by a multi-billion dollar company, all that can save you is the ethical limits of their legal team's consciences.
It would probably be legal to do this, as long as no one could reasonably show that you intentionally trained the LLM on said leaked source code with the intent to reproduce the product.
Of course, civil suits could be another matter entirely. If you pick a product to rip off that's owned by a multi-billion dollar company, all that can save you is the ethical limits of their legal team's consciences.