The garage-door firmware checks a button-sequence password on the device itself and then sends an "open" request. Why is that design weak, and what is a better one?
Anyone who can read or debug the device can recover the password or skip the check, because both the secret and the decision live in the firmware. A better design keeps the secret out of the firmware and puts the decision on a server that the device has to prove itself to.
The weakness is structural, not a coding bug: the device both stores what the correct answer is and decides whether it was given. Physical access plus a debugger reaches both.
Better designs move one or both out of reach:
- Don't store the secret in plain form. Keep a salted, slow hash instead of the password so it can't simply be read out. This raises the bar but does not stop someone from skipping the check.
- Put the decision elsewhere. The door controller (or a server) verifies the code. The button pad only forwards what was pressed, so tampering with the pad gains nothing.
- Authenticate the device. Give each device its own key and have it sign its requests (ideally with a key kept in protected storage), so a stolen password alone isn't enough and a single device can be revoked.
- Lock the hardware. Disable JTAG and enable flash encryption and Secure Boot (next card), so the firmware can neither be read nor changed.
Tip: Ask two questions of any device-side check: "Who stores the secret?" and "Who makes the decision?" If the answer to both is "the device in the attacker's hand", the check is advisory.
Go deeper:
OWASP — IoT Top 10 (2018) — hard-coded credentials and lack of physical hardening are on the list.