by mschuster91 · 9y ago · 0 comments
To make matters worse, I guess there are ways for the USB slave device to fingerprint the OS (or: hardware!) running on the host... something like a "pwn me" USB stick working on all three major platforms (OS X, Linux, Windows) or game consoles is certainly possible. And I can perfectly imagine that there are ways to exploit the actual USB controller hardware, which gives unfettered memory access.
Well, sure, the hardware standards required to achieve this are complex. But looked at from another angle, the software required to handle this is simpler than before.
Before, a kernel had to have, effectively, fifteen drivers for the various IO controller-hub chips in the system, and then fifteen matching subsystems to manage their respective protocol stacks (i.e. physical, link, and [for several of the standards] network layers in the OSI model.)
With consolidation, now you have maybe half as many drivers for controller-hubs (because both USB-C and Thunderbolt are managed by the same hub, etc.) and far fewer stacks, because there's only one stack per common protocol standard. Every port being "unified into" a {USB, PCIe, DisplayPort, HDMI, ...} port means that now, that set of protocols—taken together—are now where a lot of the eyes in kernel development end up. So each of these protocol stacks is being picked over far more thoroughly than before.
It's the same thing that happened when USB obsoleted all the previously-proprietary standards for OSI layers 1 and 2 over serial or parallel ports: suddenly, instead of 1500 individual implementations of those layers [either as proprietary drivers from the manufacturer, or as reverse-engineered parts of Linux] you had one, much-more-well-done OSI layer-1/2 driver for USB. There were still 1500 drivers, for whatever those devices did on top of OSI1+2 (though that number gradually decreased as common HAL driver standards for things like HID peripherals emerged), but those drivers now each had much less code and therefore much less attack surface. (And, as well, a lot of those drivers no longer "did" anything much at the hardware level, instead just packing and unpacking packets from the bus into data for a system service to hold onto, and therefore these drivers could now be more heavily sandboxed by the OS. This is ~half of why Windows XP crashed less than Windows 9x: a USB device-driver crash was, almost always, a non-fatal event.)
Yes, in the bad old days, we had dozens or hundreds of different drivers for specific network cards, serial cards, parallel port chips, audio cards, floppy controllers, disk drivers, etc., plus the tangled mess of scsi and ata/sata/pata storage stacks, tcp/ip/tokenring/ethernet/netbios/smb/appletalk network stacks, tty/vtty/serial terminals, and so on. Bugs in the higher-level stacks, like sata, would be impact very broadly. But a bug in one specific network card driver would, generally, only affect the subset of people who actually had that specific network card. And many of those old drivers were not really all that complicated, because they were specific and narrowly tailored. Buggy as anything too, of course, and didn't get much scrutiny due to the huge variation in software.
Now everything is subsumed under a massive IO controller-hub chip driver. At least the last time I checked, all those tangled upper-level stacks are still there, but they are just entwined with a hugely complex mess of usb/thunderbolt/usb-c mess. So you'd still have all the complexity of a sata stack, but that's nested on top of a scsi stack, sitting on a PCI stack, all nested inside a USB-C stack.
Medium sized company. It's your job to pick a stack. Your performance will be evaluated on whether a team of security consultants can hack you. Your stock grant will either multiply 100x or divide 10x depending on whether you get hacked. You get 1 month of unfettered access to all employee workstations. The consultants get one week to try to break in. Do you want a modern OS with its USB stack and whatever high level drivers, or do you want to put everyone on old school machines with bare metal drivers?
Assume the attackers get to know which choice you made.
https://securinghardware.com/articles/SLOTSCREAMER/
also duplicated by others, back in 2015: https://www.extremetech.com/mobile/197005-new-apple-malware-...
And given you can easily reprogram thumb drives and such, it's easy to do evil stuff with them. You can plug a thumb drive with a reprogrammed firmware which will detect the OS based on IO patterns and then it can tell the OS it's also a keyboard and runs command for you.
https://srlabs.de/bites/usb-peripherals-turn/ https://srlabs.de/wp-content/uploads/2014/11/SRLabs-BadUSB-P... https://github.com/brandonlw/Psychson
https://www.computerworld.com/article/2690790/tools-for-crea...
From the article: "During their Derbycon demonstration, which is available on YouTube, the two researchers replicated the emulated keyboard attack, but also showed how to create a hidden partition on thumb drives to defeat forensic tools and how to bypass the password for protected partitions on some USB drives that provide such a feature."
If everything goes well (all the input is as expected), you'll walk the path straight and reach your goal.
Bad software (most of it, honestly) has no guardrails: do something wrong, take one step to the side, and you fall crashing off the narrow path. Robust software has guardrails, handles all the error conditions, to make sure you stay on the path (or at least return to the start).
Most software is tested against expected input. It's already a lot of work to get things working for the expected case, it's usually enough to stop there. Make the path, expect smart hikers, omit guardrails. This is why stuff still works: most of the time, things go as expected.
It is a huge investment to test against all error conditions. I only know of the Space Shuttle that had the robustness requirements to shoulder the cost of implementing that. As I recall, their conventional productivity metrics were abysmal (<1 LoC/day/engineer?), but it was robust.
I've worked on High-Availability equipment. The software quality wasn't better than elsewhere, but the recovery mechanisms were much better. For example, all mission-critical data was mirrored to redundant HW/SW, and there was a standby system ready to pick up whenever the active copy crashed... which wasn't too often, but it happened. This is similar to Netflix' "Chaos Monkey" approach to software design.
What's 0.5 of a bug, anyway?
I don't remember the last job where I was hired where my major contribution was to add something, usually I'm just removing cruft and simplifying things and that's what makes things work again.