There have been a number of cases when border security officials have requested passwords to mobile data devices as indicated in the questions US and Canada border crossing and computer privacy: What do I need to know? and Do I need to provide PIN or password for my digital accessories, when entering Canada? .
I am wondering even if you have nothing on your device to hide (clean install with innocent activity logs), your user account is a restricted account, your WiFi switch is off and the network drivers are incompatible and the firewall blocks all network ports, the battery is flat and your charger is checked in and the USB ports deliver excessive voltage when the unit is working.
Assuming that officials have your password and have the machine out of your view for some moments how easy would it be for them to leave some residual compromise on your system that would be a pain to detect?
EDIT:
In response to answers and comments.
I am hoping to determine if it is worth owning a device after it has had the 'greasy' hands of border security on it. I tried exclude the external data vectors, assume you have dropped super-glue in the USB connectors on phone and laptop USB connectors generate 350V spikes on the data lines.
My worry was more in the line of can they simply try and connect it to a local WiFi sniffer to determine the MAC address or some other meta-data and say track you later on now that the device ID is positively linked to your passport (identity) for future data aggregation. I suppose the real question is how much damage can they do by seemingly doing nothing?
Personally I may not get chance to travel to US or Canada but would possibly use a sacrificial phone and junk it after my visit to such countries, I'm just wondering what advice to offer friends who travel that are not quite as security concious.
I suppose for my friends and I there should be an alternate question that does not include physical hacks to our daily devices just to harass border guards but might simply include a software/firmware tidy up check-list.
SECOND EDIT:
It looks like I should add Australia to the list of countries that one needs to be wary of. In this case it looks like it took 90 minutes for the officials to work their way through a phone and laptop that had been unlocked and it looks like the phone was tampered with.