How are the owners traced? Is it safe?

When a pet is found, the animal professional (e.g. vet or a dog warden) will scan for a microchip. The unique code will be read, and contact will be made with the database the pet is registered with. The staff at the database will perform security checks before releasing any contact details.