Introduction
CAN was designed in the 1980s for a network that nobody outside the car could reach. The harness was sealed, every node came from the manufacturer or its suppliers, and the only way to put a frame on the bus was to splice a wire into it. Under those assumptions security was not a requirement, and the protocol has none: no way to tell who sent a frame, no way to prove a frame is genuine, and no encryption. Every one of those assumptions has since failed. The OBD-II diagnostic port has been mandatory since the 1990s and accepts any device you plug into it. Telematics units connect the bus to the mobile network, infotainment systems bring Bluetooth, Wi-Fi and USB, and even the tyre-pressure sensors are a radio link. In 2015 two researchers, working from a laptop miles away through a Jeep's cellular connection, killed its engine, disabled its brakes and, with the car in reverse, turned its steering wheel, and 1.4 million vehicles were recalled.
This article is an engineering introduction rather than a scare story. It explains why CAN is so trusting, walks through the three classic attacks, spoofing, replay and flooding, and shows how each one looks on a bus analyser. It then covers the defences in use today: intrusion detection, authenticated messaging and secured diagnostic access, with a closing word on network segmentation. The examples run on the Proteus Automotive CAN simulation, whose security demonstration includes a rogue attacker node, a passive intrusion detector and an authenticated engine message, and whose immobiliser model adds seed-and-key access. Everything shown is real protocol behaviour; only the bus is simulated, which is what makes it safe to attack. It builds on Anatomy of a CAN Transmission and Finding Faults on a CAN Bus.
Why CAN Trusts Everyone
Three properties of the protocol, each a sensible design decision in 1986, add up to the whole problem. First, a frame carries an identifier that names the message, not the sender. There is no source address anywhere in a CAN frame, so a receiver cannot distinguish the engine ECU's speed message from an identical frame sent by any other node on the bus. Second, every frame is broadcast and any node may transmit any identifier; there is no admission control of any kind. Third, arbitration hands the bus to the lowest identifier, so a node that chooses to use low identifiers wins every contest, and the protocol's own priority mechanism becomes a weapon.
Note that the CRC protects against noise, not against intent: a forged frame carries a perfectly valid CRC because the forger computed it. Also, acknowledgement comes from any receiver, so a forged frame is acknowledged as readily as a genuine one. CAN therefore provides strong integrity against accidents and none against adversaries. That is not a flaw in the protocol so much as the consequence of a design decision that was right for its time and now has to be compensated for above the protocol, in the ECUs and in the network architecture.
Spoofing
Spoofing, or masquerading, is sending a frame under an identifier that belongs to another node, with a payload of your choosing. In the Proteus security demonstration the attacker node has a SPOOF mode that transmits a chosen identifier and payload at a chosen rate. Point it at the engine data identifier with a payload of zeros, at the same rate as the genuine message (100 ms in the sample, which is the attacker's default), and the instrument cluster's rev counter drops to zero while the engine is running, because the cluster has no way to prefer one sender over the other. On the analyser the tell-tale is the one described in the previous article for a misconfigured node: two payloads alternating under a single identifier, and that identifier arriving at twice its normal rate. The only difference between the fault and the attack is intent.
In practice a receiver acts on the last value it saw, so an attacker who transmits faster than the genuine sender wins most of the time, and one who transmits much faster wins nearly always. An attacker who deliberately starts its frame in the same bit time as the genuine one, with different content, causes bit errors on both nodes and steps both transmit error counters by eight. Both counters climb together at first, but once both nodes pass 127 and become error passive the asymmetry appears: the victim's passive error flag is recessive and stops nobody, so the attacker's frame now completes and earns it a decrement, while the victim keeps failing and keeps adding eight. Only the victim reaches bus-off, after which the attacker owns the identifier outright. That is a documented attack, and it turns the fault-confinement mechanism from article 2 against the node it was meant to protect.
A spoofed engine speed. The cluster believes the forged frame, and the analyser shows two payloads alternating under one identifier at double the normal rate.
Replay
Replay needs no understanding of the message at all. Record a frame the bus has already accepted, the one that unlocks the doors, say, and send it again later. The CRC is valid because it is the real frame. The identifier is legitimate. The payload is exactly what the receiver expects. Nothing in CAN distinguishes the copy from the original, because nothing in a frame says when it was sent or how many times. The attacker node's REPLAY mode does precisely this: it captures the most recent genuine frame of a chosen identifier and re-emits it repeatedly at its own rate. On the analyser the replayed frame is byte for byte identical to one that went before, and a receiver can only tell the difference if it knows that the content ought to have moved on. That knowledge is called freshness, and it is the subject of the authenticated messaging section below.
Flooding
Flooding is the babbling node from article 2 done on purpose, with a low identifier. Arbitration always prefers the lower value, so a node sending 0x000 back to back owns the bus and nothing else gets through; even a mid-range flood starves everything above it, and the starved consumers time out to their defaults without a single protocol error, because every flooding frame is valid. The attacker node's FLOOD mode sends its target identifier every half millisecond, roughly half the bus at 500 kbit/s: enough to load it heavily and trip the detector. As with the accidental babbler, the bus load figure and the per-identifier frame rate name the culprit.
Detecting an Intrusion
Since the bus cannot refuse a frame, the first line of defence is to notice. An intrusion detection system (IDS) is a node that receives everything and transmits nothing except its own alerts and its replies to a diagnostic tester. The Proteus IDS node applies three rules. An allow-list of identifiers, which you populate for the bus in front of you: any application frame (below the diagnostic range) whose identifier is not on the list is flagged as a rogue, which catches an attacker using an identifier the bus has never seen but not one who borrows a legitimate identifier. A rate rule: an identifier arriving faster than it should is flagged as a flood. In the demonstration the rule is a fixed threshold, eight consecutive gaps under a millisecond; a rule tuned to each identifier's expected period would also catch a spoofer whose extra frames double an identifier's rate, and the fixed threshold would not. And a freshness and authenticity rule for a designated message that carries a counter and a message authentication code, which catches replay and forgery and is explained in the next section. When a rule trips, the node broadcasts an alert frame of its own naming the rule and the offending identifier, shows a warning in its window, and stores a diagnostic code that a scan tool can read afterwards.
Note that an IDS detects but it does not block. The only way any node can stop a frame on CAN is to destroy it with an error flag, which is a blunt instrument that a determined attacker can turn back on the defender, so most deployed systems log and alert rather than intervene. Also, a careful spoof, using a legitimate identifier at the legitimate rate and silencing the genuine sender first, passes the first two rules unseen. That is why the third rule exists, and why deployed systems add plausibility tests on content of the kind article 2 recommended for faults, and research systems have gone as far as fingerprinting each transmitter by the tiny drift of its clock.
The intrusion detector has caught the flood. Its own alert frame appears on the bus, and the rule and identifier are named in its window.
Authenticated Messaging
If the bus cannot tell who sent a frame, the frame must carry its own proof. The pattern used in production vehicles, standardised by AUTOSAR as Secure Onboard Communication (SecOC), gives up part of the payload to two extra fields. A freshness value, usually a counter that advances with every transmission, defeats replay: a receiver that has already seen counter 43 rejects a frame carrying 41. A message authentication code (MAC), computed over a message identifier, the payload and the counter using a secret key shared between sender and receivers, defeats forgery: a node without the key cannot produce a MAC that verifies, and cannot alter a byte of a genuine frame without invalidating the one it carries. The receiver recomputes the MAC, compares, checks the counter has advanced, and only then acts on the payload.
In an eight-byte Classical CAN frame every byte spent on security is a byte of signal lost, so production systems truncate the MAC to 24 or 28 bits and the freshness value to a few bits, with the receiver reconstructing the rest, and CAN FD's 64-byte payload is one reason it is spreading. Every frame costs a MAC computation at both ends, which is why modern ECUs have hardware AES. The key has to reach every node securely and stay secret for the life of the vehicle, and the counters have to survive a reset without repeating. Authentication also does nothing to hide the content; a listener still reads the engine speed. That is rarely a concern on CAN, where the value of the data is low and the value of controlling it is high.
In the Proteus demonstration the engine ECU can be switched to emit an authenticated companion to its engine data message, with six payload bytes, a one-byte counter and a one-byte MAC, and the IDS node verifies it. Replay that message with the attacker and the counter fails to advance; spoof it and the MAC fails to verify; in both cases the IDS raises its freshness alert. Note that the MAC in the simulation is a short keyed hash, chosen so the mechanism is visible in a lesson. It shows exactly why authentication defeats spoofing and replay, but it is not cryptographic, and a production system uses a proper cipher-based MAC such as AES-CMAC.
The authenticated message with its counter advancing. The replayed copy carries a counter the detector has already seen, and is flagged.
Secure Access: Seed and Key
Ordinary traffic is only part of what travels on a vehicle bus. Diagnostic services, defined by the Unified Diagnostic Services standard (UDS, ISO 14229), let a tester read and clear codes, but also reflash firmware, write calibration data, run actuator tests and, in an immobiliser, authorise a new key. Those operations must not be available to anyone who plugs into the diagnostic port, and UDS protects them with the SecurityAccess service, number 0x27. The tester asks for a seed, the ECU replies with a value that should be fresh each time, the tester transforms the seed into a key using a secret algorithm and sends it back, and only if the key matches does the ECU unlock the protected services. Wrong keys are answered with a negative response, a small number of wrong keys triggers a lockout, and a request during the lockout is refused with a different negative response, all with codes defined by the standard.
Seed-and-key protects diagnostics, not normal traffic; it does nothing against spoofing or replay of ordinary frames. Its own weakness is the secret algorithm, which has to live inside the ECU's firmware and inside every authorised tester, and for many vehicles it has been extracted from one or the other and published. The Proteus immobiliser implements the full exchange, including the lockout, with a deliberately weak key transform so a class can see both how the mechanism works and why a constant that can be read out of the firmware is not a secret. For the same reason its seed is a fixed value by default, so a worked example is reproducible, with a rolling seed available as an option. The 2020 edition of the standard added an Authentication service, number 0x29, based on certificates or on challenge and response with proper keys, precisely to move away from shared secret algorithms.
On the simulated bus the exchange runs as follows. The immobiliser answers UDS on its physical diagnostic identifier, 0x7E0 plus its ECU index, which is 5 by default, so requests go to 0x7E5 and replies come back on 0x7ED. UDS rides on the ISO-TP transport, whose single-frame format puts the payload length in the first byte and pads the rest of the eight bytes; the simulation pads with 0xAA. The bench is two parts on one bus: the immobiliser model and the CAN Bus Analyser, whose Send tab is the tester. The immobiliser also broadcasts its own status message, IMMO_STATUS on 0x180, every 200 ms, and the first byte of it is the thing to watch alongside the exchange: bit 3 is the SecurityUnlocked flag and bits 4 to 6 are the immobiliser state, so with no key fob present the byte reads 00 while locked, 08 once unlocked and 40 in lockout. The shipped database names the message but does not yet list its signals, so read that byte from the Frames tab rather than the Signals tab.
Step 1, the bench. An immobiliser and the analyser on one bus. The immobiliser's properties fix its diagnostic index at 5 and its seed at A1B2C3D4, so the bytes below are reproducible.
Step 2: ask for a seed. In the Send tab set the identifier to 0x7E5 and the data to 02 27 01 AA AA AA AA AA: two payload bytes, SecurityAccess, requestSeed. Send it once. The immobiliser replies on 0x7ED with 06 67 01 A1 B2 C3 D4 AA: six payload bytes, positive response to 0x27, sub-function 01, then the four-byte seed. In the frame list the request and reply sit one above the other, about half a millisecond apart, and the first byte of IMMO_STATUS still reads 00.
Step 2, the seed. The request on 0x7E5 and the reply on 0x7ED, with the seed in bytes 3 to 6 of the reply.
Step 3: send the key. Compute the key. In this teaching model it is the seed XOR 12345678, so A1B2C3D4 becomes B38695AC. Send 06 27 02 B3 86 95 AC AA. The reply is 02 67 02 AA AA AA AA AA, the UDS field in the immobiliser's window changes from locked to unlocked, and on the next IMMO_STATUS frame the first byte reads 08. The immobiliser's protected diagnostic services are now open. Notice to whom: CAN has no source address, so they are open to whatever addresses 0x7E5 from now on, not to the particular tester that sent the key. In the simulation the unlock is visible only as that flag; the model reports it rather than gating anything behind it.
Step 3, unlocked. The correct key is answered 67 02, the immobiliser's UDS field reads unlocked, and bit 3 of its status byte is set.
Step 4: get it wrong. Stop and restart the simulation so the immobiliser is locked again, request a seed as before, then send 06 27 02 00 00 00 00 AA. The reply is 03 7F 27 35 AA AA AA AA: negative response, to service 0x27, code 0x35, invalidKey. Request a seed and send a wrong key twice more. The attempt counter in the immobiliser's window climbs to 1 and then 2. The third wrong key is answered 03 7F 27 36 AA AA AA AA, exceededNumberOfAttempts; the immobiliser's state changes to Lockout, its status byte reads 40, its attempt counter resets to 0, and for the next ten seconds of simulated time any SecurityAccess request at all is answered 03 7F 27 37 AA AA AA AA, requiredTimeDelayNotExpired. Send a key without asking for a seed first and you get code 0x24, requestSequenceError, because the standard insists on a fresh seed for every attempt. One practical note: stopping and restarting the simulation clears an unlock but not a lockout in progress, so if you want to repeat the exercise, let the ten seconds run out first.
Step 4, locked out. Three wrong keys, the negative responses the standard defines for them, and the lockout that follows.
Everything in that exchange is standard UDS except the key transform, and the frames are the ones a real tester would put on a real bus. Doing it by hand shows that the security lives entirely in the transform: an attacker who can read the bus sees the seed and the correct key go past in plain sight, and if the transform is guessable, as this one deliberately is, that is all they need.
The same immobiliser shows the other kind of secure access, the physical key. A passive entry system runs a challenge and response between the car and the fob: the car sends a fresh random challenge, the fob answers with a code derived from the challenge and its own secret, and an old code replayed from a previous session is rejected. That is freshness again, in radio rather than on the bus, and it is why the practical attack on passive-entry cars is not replay but relay, carrying the live radio conversation between a fob indoors and a car on the drive.
Gateways and Segmentation
The last defence is architectural: do not put everything on one bus. A modern vehicle runs several CAN networks, typically powertrain, chassis, body and diagnostics, with infotainment and telematics separate again, joined through a central gateway that forwards only the messages its routing table lists, in the direction listed. The diagnostic port sits on its own segment behind the gateway, so a plug-in dongle cannot transmit on the powertrain bus, and a compromised infotainment unit cannot reach the brakes without getting through the gateway first. In the 2015 Jeep case the attackers reached the vehicle buses by reprogramming the microcontroller that connected the infotainment unit to them. Whatever bridges an outside connection to the bus is the most security-critical part of the car.
Proteus offers two ways to build this: the gateway sample, with a microcontroller running your own firmware between two CAN segments and forwarding only the identifiers you choose, and the CAN-to-LIN gateway model with its explicit, directional route map. Since July 2024 every new vehicle sold in the EU has needed a certified cyber-security management system under UN Regulation 155, with ISO/SAE 21434 describing the engineering process. The regulation prescribes a process rather than techniques, but segmentation, intrusion detection, authenticated messaging and secured diagnostic access are the mitigations it most often reaches for.
Summary
CAN trusts every node because in 1986 every node could be trusted. A frame names its message and not its sender, anyone may send anything, the lowest identifier always wins, and the CRC checks for noise rather than intent. From those four facts follow the three classic attacks: spoof a legitimate identifier and the receivers believe you, replay a genuine frame and nothing can tell it from the original, flood with a low identifier and the bus is yours. The defences all live above the protocol. An intrusion detector watches for identifiers, rates and freshness it does not expect, and raises the alarm without being able to block. Authenticated messaging spends payload on a counter and a MAC so that receivers can reject the replayed and the forged. Seed-and-key, and its 2020 successor, guard the diagnostic services that could reprogram the car. And a gateway keeps the port a stranger can reach away from the bus that stops the car. The final article in this series leaves security behind and follows the ordinary messages of a working drivetrain around the bus.
Everything in this article can be run on a simulated vehicle bus. The Proteus Automotive CAN security demonstration includes an attacker node with SPOOF, REPLAY and FLOOD modes, a passive intrusion detection node with allow-list, rate and freshness rules, an authenticated engine message the detector verifies, and the security_demo sample design is the place to start for all three. The immobiliser, with its full UDS SecurityAccess seed-and-key driven from the analyser's Send tab, is in the showcase design, and the gateway sample shows segmentation with your own firmware in the middle.
All content Copyright Labcenter Electronics Ltd. 2026. Please acknowledge Labcenter copyright on any translation and provide a link to the source content on www.labcenter.com with any usage.Get our articles in your inbox
Never miss a blog article with our mailchimp emails
Automotive CAN Simulation
A complete vehicle network in software: behavioural car-part models, any Proteus VSM processor as an ECU, and a security demonstration with an attacker, an intrusion detector and authenticated messaging on a bus that is safe to attack.
Ask An Expert
Have a Question? Ask one of Labcenters' expert technical team directly.