How to safely buy a second hand phone UK ?

Is there any safe way to buy a second hand phone in the uk ?

What does the manufacturer need to ascertain legal proof of ownership of the IMEI ? if someone decides to phone the mfr to block the IMEI after sale ?

context: Interested in buying a phone from FB market place, or second hand , how do I ensure that I will not be left with a brick ? i.e. that it isn't stolen ?

Cheers