There are a lot of USB devices which can be fatal to your innocent machine. An office worker leaving his computer even for a short span of time is making it vulnerable to USB-led attacks.
It doesn’t really matter if the computer is locked or not. A possible workaround could include disabling the USB ports completely but that won’t be a practical approach in the long run.
A security researcher @errbufferoverfl spared out some time from his schedule and created a Python-based open source tool called USB Canary. Available on GitHub, the tool constantly monitors a computer’s USB ports.
If USB Canary detects any USB device being plugged or unplugged from the machine, it uses the Twilio API to send an SMS to the owner. Also, it can send messages on Slack. This would allow other team members to sense a foul smell.
There are various existing tools that can do a similar job but USB Canary works even if the computer is locked. Currently, the tool is only available for Linux-based operating systems. But the developer is working on versions for Windows and MacOS following the immense appreciation he got from the community.
USB Canary can also be implemented by the system administrator in organisations which restrict employees from attaching any sort of USB devices to their work machines. You can find all the details about USB Canary on its Github repo.