If he markets a product that he does not possess, does the profit belong to him?
Firstly:
If your friend obtained the product as the result of a mistake that he made in his accounts, as you say, then this product is not permissible for him, rather it belongs to the company and it is not permissible for anyone to help him in selling it. What he has to do is correct the mistake and return the product to the company.
Secondly:
Whatever is taken unlawfully is regarded as coming under the same ruling as property seized by force, and must be returned to its owner if it is still in existence, otherwise something similar should be given to him if something similar exists, otherwise its value should be given to him.
If the one who stole it deals in it and makes a profit, then he must return this profit to the owner of the item, because it is the profit on his wealth.
Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allaah have mercy on him) was asked about a man who had some money left in trust with him, and he invested it and made a profit, then he returned the money to the owner without the profit.
He replied:
If someone entrusts you with something, you have no right to dispose of it without his permission, and you must look after it as similar things are looked after. If you dispose of it without his permission then you must seek his forgiveness. If he forgives you, all well and good, otherwise you must give him the profit of his wealth or come to some agreement with him to share it equally or whatever. Agreements between Muslims are permissible except an agreement that makes a halaal thing forbidden or a haraam thing permissible. End quote from Fataawa al-Shaykh Ibn Baaz (19/411).
Thirdly:
The wages that you received for facilitating this trade must be given in charity, because you received them as the result of a haraam action.
We ask Allaah to enable you to repent sincerely.
And Allaah knows best.