I have yet to see anyone answer this question convincingly, however if you are buying shares outright (no margin) then technically there is no risk because the shares are yours, 100%. If you are buying on margin then you are hypothecating your stock to a broker and this could become a grey area in the event of a bankruptcy. Tha law in the US was clear - no commingling of funds, yet customers who owned bars of gold outright are being robbed by the trustee.
The trustee overseeing the liquidation of the failed brokerage has proposed dumping all remaining customer assets—gold, silver, cash, options, futures and commodities—into a single pool that would pay customers only 72% of the value of their holdings. In other words, while traders already may have paid the full price for delivery of specific bars of gold or silver—and hold “warehouse receipts” to prove it—they’ll have to forfeit 28% of the value.
I haven't kept up with this so there probably is an update. However my concern in the UK has been about buying shares via a nominee account where you are only the beneficial owner and the trustee is the registered owner.