Protect your device from being infected by a USB drive by following these steps:
- Disable or restrict the autorun capability in Windows or OS X.
- Configure the operating system’s behaviour when connecting a USB to the device.
- Scan the USB drive to detect and remove any malware inside.
- Always have up-to-date antivirus installed on your device.