Yes, it is legal.
The passport office itself does this when a British Citizen living outside the UK renews their passport. The new passport is produced in and sent from the UK.
Note that different procedures and different forms are needed fro renewing a passport outside the UK to renewing one in the UK. It also costs nearly twice as much to renew a passport if you live outside the UK.
A better question might be what possible legal/moral justification do you have for accessing someone else's passport details. There's no way I know of to get them other than to ask the person the passport belongs to, and this is exactly how it should be.
NO, it is illegal anywhere for someone else to use your passport
no
No, it is not legal to use someone else's license plates.
No, it is not legal to cash a check with someone else's name on it without their permission.
No, it is not legal to use someone else's credit card without their permission.
No, it is not legal to open someone else's mail that was sent to your address.
No, you cannot obtain a passport for someone else without their authorization. Each individual must apply for their own passport.
No, it is not legal to cash someone else's check without their permission.
No, it is illegal to throw away someone else's mail.
Someone who steals something owned by someone else
No, it is not legal to use someone else's credit card without their permission. This is considered fraud and is punishable by law.