Author Topic: NON programmable / flashable keyboard for security  (Read 1675 times)

0 Members and 1 Guest are viewing this topic.

Offline pijo

  • Thread Starter
  • Posts: 3
NON programmable / flashable keyboard for security
« on: Sun, 28 January 2024, 02:14:29 »
I was reading up on some penetration testing techniques and came across different kinds of "Bad USB" techniques, for example https://github.com/justSem/badPico

Since many keyboards contain generic microprocessors, I suppose they could be reconfigured to behave like such a Bad USB device. Maybe even without the owner knowing. So from a security perspective, it might be favourable to have a keyboard with a microchip that can not be repurposed for anything other than a keyboard. Do such keyboards / PCBs exist in the mechanical keyboard space? I have tried looking around, but I'm not sure how to search for them.

Offline vvp

  • Posts: 887
Re: NON programmable / flashable keyboard for security
« Reply #1 on: Sun, 28 January 2024, 12:49:33 »
Most users in this community want to be able to upgrade/replace their firmware. That means the controllers can be flashed with something malicious.

Often you need to connect a HW programmer(*) to the keyboard to change firmware. Some keyboards come with an active bootloader which allows firmware change without a HW programmer. If a bootloader is present then it may be possible to change firmware remotely. Or it may not be possible if the bootloader requires e.g. a special button press to activate firmware upgrade.

(*) special hardware you need to connect to MCU to program/debug it

Reprogramming MCU can typically be disabled in MCU fuses using a common HW programmer. If it is disabled then you cannot reprogram it any more or you can reprogram it only with a special HW programmer (e.g. a common programmer for ATmega is 5V a special one is 12V, that means you may need to desolder MCU to be able to reprogram it at 12V without damaging the rest of the PCB).

You are being afraid about nothing significant. If you care so much then do not put in a bootloader or even disable reprogramming in fuses. In such a case attacker needs physical access to the keyboard and needs a HW programmer and maybe even desolder the MCU. In such a case, it is just easier to replace the keyboard PCB with a malicious firmware already preloaded. Almost all of your security is already compromised when you have a physical access to the device. Hell if an attacker has physical acces he can just swap the keyboard with something nasty like a mouse trap to hurt your fingers :D
« Last Edit: Sun, 28 January 2024, 12:51:08 by vvp »

Offline pijo

  • Thread Starter
  • Posts: 3
Re: NON programmable / flashable keyboard for security
« Reply #2 on: Sun, 04 February 2024, 06:59:27 »
Thanks for your reply! I agree that it is an unlikely attack vector, but I'm also just curious about this. If I understand you correctly, there isn't really a way to build a keyboard that cannot be reprogrammed/reflashed at all? It can however be made very difficult as you describe. So this is also true for, for example, a very cheap keyboard you get with a PC (e.g. Fujitsu KB410)? I always imagined these keyboards would have chips that can really only have one function.

Offline Leslieann

  • * Elevated Elder
  • Posts: 4519
Re: NON programmable / flashable keyboard for security
« Reply #3 on: Sun, 04 February 2024, 11:38:23 »
Pretty much anything that can be programmed once can be reprogrammed.
You can't really make a chip pre-programmed and removing the programming functionality is next to impossible. That doesn't mean it's easy, but it's doable.

Back to the keyboard,
Sure the keyboard is what accesses the system but it's very easily bypassed and does pretty close to nothing in terms of stopping me (or someone more determined and skilled). The keyboard firmware being hacked should be one of the least of your concerns, not just you, but almost any company as well. Too many easier points of entry that can give you far more information as keyboard firmware can't really do much on it's own and if you have access to a system why bother programming the keyboard to infect the system when you can just infect the system?

While it's a poor attack vector in terms of hacking a specific target there is nothing to stop a manufacturer from putting spyware in the firmware at the factory similar to what we see on cheap Android devices out of China. We've seen this a lot on external drives, a ton of keyboard software* and (possibly) a server motherboard.


*Don't use software a company gives you through a Google drive, stop buying from these shady fly-by-night companies altogether.
Novelkeys NK65AE w/62g Zilents/39g springs
More
62g Zilents/lubed/Novelkeys 39g springs, HK Gaming Thick PBT caps, Netdot Gen10 magnetic cable, pic
| Filco MJ2 L.E. Vortex Case, Jailhouse Blues, heavily customized
More
Vortex case squared up/blasted finish removed/custom feet/paint/winkey blockoff plate, HID Liberator, stainless steel universal plate, 3d printed adapters, Type C, Netdot Gen10 magnetic cable, foam sound dampened, HK Gaming Thick PBT caps (o-ringed), Cherry Jailhouse Blues w/lubed/clipped Cherry light springs, 40g actuation
| GMMK TKL
More
w/ Kailh Purple Pros/lubed/Novelkeys 39g springs, HK Gaming Thick PBT caps, Netdot Gen10 Magnetic cable
| PF65 3d printed 65% w/LCD and hot swap
More
Box Jades, Interchangeable trim, mini lcd, QMK, underglow, HK Gaming Thick PBT caps, O-rings, Netdot Gen10 magnetic cable, in progress link
| Magicforce 68
More
MF68 pcb, Outemu Blues, in progress
| YMDK75 Jail Housed Gateron Blues
More
J-spacers, YMDK Thick PBT, O-rings, SIP sockets
| KBT Race S L.E.
More
Ergo Clears, custom WASD caps
| Das Pro
More
Costar model with browns
| GH60
More
Cherry Blacks, custom 3d printed case
| Logitech Illumininated | IBM Model M (x2)
Definitive Omron Guide. | 3d printed Keyboard FAQ/Discussion

Offline vvp

  • Posts: 887
Re: NON programmable / flashable keyboard for security
« Reply #4 on: Sun, 04 February 2024, 12:31:27 »
So this is also true for, for example, a very cheap keyboard you get with a PC (e.g. Fujitsu KB410)? I always imagined these keyboards would have chips that can really only have one function.
For small quantities (like a keyboard needs), a chip which has only one function (i.e. a custom ASIC) is more expensive than a generic programmable controller with firmware. It is almost certain that your Fujitsu KB410 has a programmable controller inside ... and therefore it can be attacked by firmware update. But as was written, this is not a practical attack. If you have a physical access to flash firmware with a programmer then it is easier to just replace the whole keyboard with the same looking piece which has your own controller with a malicious firmware. But if you have a physical access then you may be able to put a PCIe card or a firewire device or something else which has unprotected DMA access and attack the PC and its OS directly. Even a locked down OS cannot defend itself if it does not access all new devices with IOMMU ... it likely does not ... this is typically used only for mapping hardware to a virtual machine.

The point is that you need a physical access to attack a locked down keyboard firmware. And if you have a physical access then there are much better ways to use it than going through a keyboard.

Very roughly based on google only: a standard simple MCU can go down to a few cents a piece; price of a simple ASIC design plus a minimum order (few thousands pieces) starts around $ 1e6. The result is that it is very unlikely you will find a keyboard with a custom ASIC.

Go on, tear down your off-the-shelf standard keyboard, look up the controller and find out what it is based on the markings on the chip. Though sometimes this does not help since the chip is so cheap that it does even have any usable markings. Or a marking-less package was required to obscure the design.