This question already has an answer here:
I recently bought an electronic cigarette lighter which is charged via USB. I have no idea if the company that made it is trustworthy as it is one of those no-name brands.
The thing that concerns me is that when you plug a USB device into a computer, the computer automatically communicates with the USB device to determine what type of device of it is and other information. I'm concerned that a hacker could embed some malware onto the device and attack the USB protocol itself so that when you plug the device into the computer, the computer automatically executes some malicious code.
I'm not a security expert by any means, but it does worry me. Should I just stick to using a USB wall plug charger instead of plugging it directly into my computer? Is this true of all USB devices?