All perfect praise be to Allah, The Lord of The Worlds, and may His peace and blessings be upon our Prophet Muhammad and upon all of his family and companions.
The majority of Muslim jurists are of the view that it is neither permissible for heirs to inherit ill-gotten money nor can it be passed on to them since having the right to inherit isn`t an excuse for inheriting plain, ill-gotten money. Rather, a person should get rid of it completely in order to be on the safe side as far as the injunctions of Sharia are concerned. Besides, Al-Imam Al-Ghazali (May Allah have mercy on his soul) stated in [Al-Ahyaa`, 1/129]:" The death of a person doesn`t entitle his/her heirs to inherit plain, ill-gotten money."
In this regard, Al-Imam An-Nawai (May Allah have mercy on his soul) stated in his book[Al-Majmou' 3/351]:" When a person inherits money without knowing its source or whether it is lawful or unlawful, then this money is considered lawful according to the majority of the Muslim scholars. However, if he knows that some of it is unlawful, then he should estimate, as much as possible, the exact amount through Ijtihad (Independent reasoning)."
Further, Ibn Abdeen (May Allah have mercy on his soul) stated in his book [Rad-Al-Mohtaar 5/247]:" It is impermissible to inherit ill-gotten money whether the heirs knew to whom it belongs or not, but if they did, then they should return it or give it to charity."
Moreover, holding shares in a conventional bank means becoming partners with a company whose transactions are based on Riba (Usury/interest). However, if the owner of these shares passed away, then the heirs are obliged to end the aforementioned partnership through negotiating with the bank to retrieve the stocks' value then give their profits to charity. Nevertheless, if the bank refused to end this partnership, then selling the stocks is impermissible because this kind of partnership is prohibited. In conclusion, the heirs should give the profits of stocks to the poor in order to prevent the bank from using them unlawfully. For more details, kindly check resolution No. (87) by the Board of Iftaa', Research and Islamic Studies at our website. And Allah The Almighty knows best.