Is there a inherent security threat to having border security receive your passwords?
If you gave me your phone and password for 30 seconds I could install a Remote Access Trojan completely undetectable to the common user that would give me remote access to the phone just like I had it in my hand unlocked (ie. listen to the microphone, access all files, pictures, text messages, calls, ect). If I can do that I'm sure any government is capable of the same.
So if they did that to your brand new phone, they could access any new information on it as you entered their country.
So yea, I'd consider that a bit of a security issue.
Admittedly these border officials could compromise your system.
BUT:
These are border officials. How likely is it that they will engage in illegal activity such as this? Things like this won't go unnoticed for long.
What other choice do you have? Again, they are border officials and have a legal right to inspect your devices. Not complying probably isn't a very smart thing to do.
Edit in response to comments:
Do I believe governments are above doing something illegal? Not necessarily, in the general case, but if we're talking about a working democracy, then yes, I'd suggest government, law enforcement etc is trying to stay within the limits of the law, even if there certainly are individuals who exceed their authority. I think that's a pretty healthy position to take. A bit of distrust in official statements etc is well and good. Assuming the worst about someone's (or some institution's) motives without reason strikes me as rather paranoid. I'm really having trouble imagining a secret standing order for all border personnel to infect travelers phones with spyware. If we're talking about the US border, I guess that doing this to the phones of non-US-citizens would even be legal for the CIA and the NSA, but it still sounds like a movie plot, and such a policy probably wouldn't survive discovery. And I haven't even launched into motive - what exactly would they hope to accomplish?
Also, immibis suggested to just leave your devices at home. Sure, you can do that if you don't need them. But I for one prefer to have my phone with me. It won't do me much good sitting at home.