All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
All transactions are permissible in principle except those prohibited by Sharee‘ah. Allaah The Exalted Says (what means): {But Allaah Has Permitted trade and has forbidden Riba.} [Quran 2: 275]
Transactions which involve risk, harm, ignorance, deceit, and selling unowned items are prohibited. Dealing in shares mostly involves Sharee‘ah violations.
It is impermissible to buy shares from companies or institutions which deal in Riba, provide Riba-based loans, as well as other transactions which represent cooperation in sin and aggression. It is also impermissible to buy shares of the companies which deal in or invest in what is unlawful.
The type of transaction in question is impermissible because it includes risk and selling what one does not own.
If these shares are owned by companies which produce unlawful products or deal in Riba, the matter is more serious and the prohibition is more emphasized. The fact that such transactions are carried out in foreign countries is not a justification, for Muslims are required to avoid what is prohibited under Sharee‘ah in any place.
Allaah Knows best.