When you buy a used iPhone, I recommend verifying that it was removed from the previous owner's iCloud account, if possible. You could ask for proof of purchase, or you could try to activate the phone before completing the transaction. If neither option is possible, and you end up purchasing a stolen phone, report it to the police. You could also try an iCloud lock removal service or one of the iCloud bypass tools listed above, but I don't know how successful that's going to be.