CAN Bus Security: What 10 Years of Motor Control Taught Me About the Protocol's Weak Points
CAN is a 1980s in-vehicle protocol that does exactly what it was designed to do, which is move short messages between cooperating microcontrollers inside a sealed metal box, reliably, in electrical noise, with no central arbiter. It is genuinely excellent at that. Every serious attack against it exploits the same thing: the assumption that everything on the bus is on your side.
I have written firmware for about ten years — motor control and connected industrial gear, mostly Cortex-M class parts running an RTOS or bare metal. For the last four of those, the work has mostly been some flavour of making an existing product talk to the cloud without burning it down.
That last sentence is where CAN becomes a security problem rather than a wiring problem. The products I am describing were designed as closed systems. The bus was internal, the enclosure was sealed, and the threat model was electrical noise. Then someone adds a gateway so the fleet can be monitored remotely, and a bus designed on the assumption that every participant is cooperative acquires a participant that is reachable from somewhere else. Nothing about the protocol changed. Everything about the assumption did.
‹FILL› — The two paragraphs above are drawn from what you already state publicly on /about (motor control and connected industrial gear, Cortex-M class, RTOS or bare metal, about ten years, last four spent adding connectivity to existing products) — check they are right, then add the part only you have: the bus topologies you actually shipped, and one incident where CAN's trust model caused a real problem on the bench or in the field. One or two paragraphs. The analysis below is generic without it.
The trust model, stated plainly
Four properties define the security posture, and all four are consequences of good 1986 engineering decisions:
- It is a broadcast bus. Every node sees every frame. There is no addressing in the routing sense and no way to send a frame to one node.
- There is no source identity. A frame carries an identifier describing what the message is, not which node sent it. Nothing prevents any node from transmitting any identifier.
- Arbitration is by identifier value. Lower identifier wins the bus. Priority is a property of the message type, and it is enforced by the physical layer.
- Error handling is cooperative. Any node that sees a malformed frame is expected to destroy it by asserting an error frame, and every node is expected to honour that.
Read those as an attacker and each one is a primitive. The identifier is not an identity, so it is forgeable. Arbitration is a priority channel you can occupy. Error signalling is a mechanism for making other nodes disable themselves.
Weak point one: arbitration as a denial channel
A node that continuously transmits the lowest identifier in the system wins arbitration every time and starves everything below it. No protocol violation is required — this is arbitration behaving exactly as specified.
The sharper version uses the error-handling rules. CAN nodes maintain transmit and receive error counters and are required to remove themselves from the bus once the transmit counter crosses its threshold. An attacker who injects error frames timed to a specific victim's transmissions drives that victim's counter up until it takes itself off the bus. The bus stays healthy and one node goes silent — which is far harder to diagnose than a flooded bus, because from every other node's perspective nothing is wrong.
For a control system, a silent node is not a communications fault. It is a sensor that has stopped reporting while the loop keeps running on its last value.
Weak point two: the identifier is not an identity
Given bus access, any node can transmit any frame. The receiver's only inputs are the identifier and the payload, both of which the sender chose. So a spoofed frame is indistinguishable from a legitimate one at the protocol level, and defences built on identifier filtering are configuration, not authentication.
Two things make this worse in practice. Real frames repeat at a known period, so an attacker can learn the schedule by listening and place a spoofed frame in the window where the receiver expects one. And many receivers accept the most recent value for an identifier without checking that it arrived on time or in order, which makes replay trivially effective.
Weak point three: the diagnostic path
The diagnostic layer above CAN is usually where the real authority lives — reprogramming, calibration, actuator tests, bypassing interlocks. It is nominally protected by a seed-and-key exchange before privileged services are granted.
That exchange is a recurring source of trouble, for reasons that are organisational rather than cryptographic. The algorithm is frequently a fixed transform rather than a cryptographic primitive; the key is often identical across an entire product line, because per-unit keys require provisioning infrastructure; and the algorithm reaches every tooling vendor and workshop that needs to service the product, so its blast radius is enormous. Recovering one key can unlock a fleet.
If you inherited a seed-and-key implementation and cannot say where its key is provisioned per unit, assume it is shared, and assume the diagnostic layer is your real attack surface rather than the control frames everyone worries about.
Weak point four: segmentation that is not
The standard mitigation is architectural — put the untrusted interface behind a gateway and keep the control bus separate. This is correct and worth doing. It fails in specific, repeated ways: the gateway forwards more than its documentation claims; it routes diagnostic traffic across the boundary because a workshop tool needed it to; it runs a much larger software stack than the nodes it protects, making it the most attackable device on the network; and a debug or service connector downstream of it offers direct physical access to the protected bus.
A segmentation claim is only as good as a frame-level test of what actually crosses. It is worth measuring rather than assuming.
What actually helps
You cannot add source authentication to classic CAN without changing what is on the wire. The realistic options:
- Authenticate the frames. Append a truncated MAC plus a freshness value so a receiver can reject forged and replayed frames. This is the approach the automotive secure-onboard-communication designs take, and it is the only one that addresses the root cause.
- Move to CAN FD. Classic CAN gives you eight payload bytes, and spending several of them on a MAC is often impossible. CAN FD's larger payload is what makes authentication practical.
- Monitor the bus. Frame timing on a control bus is highly regular. Off-period frames, duplicate identifiers from two sources, and error-counter excursions are all detectable, and detection is deployable on existing hardware where authentication is not.
- Provision per-unit keys. Whatever scheme you adopt, a shared fleet key converts one compromise into all of them.
// Receiver side: authenticate before the value reaches control logic.
// Truncated MAC over (id, payload, freshness); freshness must advance.
if (!mac_verify_trunc(frame.id, frame.data, frame.dlc,
rx_freshness, frame.mac, &key)) {
stats.auth_fail++;
return; // drop; do not update the signal
}
if (frame.freshness <= last_freshness[frame.id]) {
stats.replay++;
return; // stale or replayed
}
last_freshness[frame.id] = frame.freshness;
signal_update(frame.id, frame.data);
Two costs are worth stating honestly. The MAC has to be computed inside the frame period on an MCU that is already busy, which is a real budget question and not a footnote. And freshness state has to survive resets and node restarts without desynchronising the bus, which is the part that consumes the schedule. The cryptography is the easy half.
‹FILL› — Your view on what is actually deployable on a constrained part: where the MAC cost landed in your timing budget, or why you concluded monitoring was the pragmatic answer instead. One or two paragraphs, concrete about the part and the loop rate.
Why this is now a compliance question
A CAN-based product with any network-facing interface is a product with digital elements, and the essential requirements expect protection of the integrity of transmitted data and appropriate confidentiality and access control. "The protocol does not support authentication" describes the protocol, not a conformity position. Where authentication is genuinely infeasible, the defensible answer is a documented threat model plus compensating controls — segmentation you have tested, monitoring you actually run, per-unit diagnostic keys — rather than silence.
What to do on Monday
- Put a logger on the control bus of a shipping product for an hour. Write down the identifiers, their periods, and which nodes should be transmitting each. Most teams do not have this document.
- Find out whether your diagnostic key is per-unit or per-product-line. If nobody knows, it is per-product-line.
- Test your gateway at frame level: transmit on the untrusted side and record what appears on the protected side. Compare against what the design says should cross.
- For one safety-relevant signal, work out what the receiver does with a value that is plausible but stale. If the answer is "uses it," you have a freshness problem independent of any attacker.
Shipping before December 2027? Grab the CRA Compliance Checklist for Embedded Engineers — free, 3 pages, no marketing.
FAQ
What I'm writing about next
A bench walkthrough of CRA Annex I, requirement by requirement, against a real ESP32-based product — what passes, what fails, and what an auditor will probably argue about.
One post a week, plus the CRA checklist on signup.
No marketing.
If this was useful, the best compliment is forwarding it to a teammate.