CAN SECURITY
Introduction
Classical CAN was designed for reliability, not security. A frame carries no sender identity, is broadcast to every node, and is protected only by a checksum that guards against accidental corruption, not deliberate forgery. Any node on the bus can therefore transmit any identifier at any time, and every receiver believes what it hears. On a real vehicle these properties are the root of most in-vehicle network attacks.
The CAN security models let you demonstrate those weaknesses and their countermeasures entirely in simulation, where mounting an attack is safe, repeatable and fully observable on the CAN Bus Analyser. They follow the natural teaching arc of automotive cybersecurity: mount an attack, detect it, authenticate the traffic so the attack no longer works, and finally control access to a protected function. Two dedicated models provide the attack and the detector, and two mechanisms already built into the behavioural nodes provide the defences.
| Stage | What it demonstrates |
| Attack | The Attacker node spoofs, replays and floods the bus, exploiting the absence of source authentication. |
| Detect | The Intrusion Detection node watches passively and raises an alarm when traffic breaks its rules. |
| Authenticate | Secure Onboard Communication adds a freshness counter and an authentication code, so forged and replayed frames can be told from genuine ones. |
| Control access | UDS SecurityAccess gates a protected function behind a seed and key exchange. |
The authentication and access-control mechanisms here are deliberately simplified for teaching. The message authentication code is a fast keyed hash, not a cryptographic one, and the seed-to-key transform is a plain exclusive-or. They show clearly why authentication defeats spoofing and replay, but they must never be presented as, or reused as, real vehicle security.
The Attack Surface
Three properties of classical CAN, all covered in the CAN Protocol Primer, are what an attacker abuses:
- No source authentication. A frame names a message, not a sender, so a rogue node can transmit a genuine ECU's identifier and no receiver can tell the difference. This is the basis of a spoofing attack.
- No freshness. A frame carries nothing to say when it was sent, so a previously captured frame can be replayed later and accepted as current. This is the basis of a replay attack.
- Shared medium with priority arbitration. A node that transmits a low identifier back to back monopolises the bus and starves genuine traffic. This is the basis of a denial-of-service, or flood, attack.
Each of these is a single click in the simulation, and each has a matching detection rule and defence in the sections that follow.
The Attacker Node

The Attacker popup with its four attack-mode buttons, showing the transmit count climbing while an attack is active.
Device: ATTACKER
Models a rogue ECU connected to the bus, the offensive counterpart to the intrusion detector. It transmits only to the simulated bus, so an attack can never leave the design. Its behaviour is chosen live from the popup or preset with the ATTACK property, and it carries no database and raises no trouble codes, because it is the threat rather than a diagnostic subject.
The popup offers four modes, selected by the buttons Off, Spoof, Replay and Flood. The mode can be changed while the simulation runs, so an attack can be started and stopped as the class watches the effect.
| Mode | Behaviour |
|
Off |
A passive sniffer. The node listens but transmits nothing. |
|
Spoof |
Periodically transmits the target identifier with a crafted payload, colliding with the genuine sender so that receivers act on the forged data (a fake road speed, a fake unlock request). |
|
Replay |
Captures the most recent genuine frame of the target identifier from the bus, then re-emits that exact frame later. Because classical CAN has no freshness, the receiver cannot tell it is stale. |
|
Flood |
Transmits the target identifier back to back at high rate, loading the bus and starving lower-priority traffic. |
Example
Point TARGET_ID at the vehicle speed message and select Spoof with a payload of zero: the dashboard speedometer is pulled towards zero even as the genuine Vehicle Dynamics node continues to report the real speed, because both frames now appear on the bus under the same identifier.
The Intrusion Detection Node

The Intrusion Detection popup in its two states: green MONITORING with no intrusions, and red THREAT DETECTED naming the tripped rule and the offending identifier.
Device: IDS_NODE
Models a passive intrusion detection monitor. It registers on the bus so that the framework delivers every frame to it, but it transmits no traffic of its own except its alert broadcast and its diagnostic responses. It never disturbs the bus it watches, so it is safe to drop into any design. When traffic breaks one of its rules the popup turns red and names the threat, a security trouble code is stored for a scan tool to read, and an IDS_ALERT frame (0x250) is broadcast so that other nodes, such as the instrument cluster, can react.
Three rules run in parallel, each aimed at one of the attacks above:
| Rule | Trouble code | Trips when |
| Unknown identifier |
U07A0 |
A frame arrives whose identifier is not in the VALID_IDS allow-list. This catches a spoofed or rogue identifier. The rule is off until an allow-list is supplied. |
| Flood |
U07A1 |
One identifier arrives with a gap shorter than FLOOD_GAP_MS, sustained for FLOOD_HITS frames. This catches injection and denial of service. |
| Freshness |
U07A2 |
The protected message named by SECOC_ID arrives with a bad authentication code or a counter that has not advanced. This catches forgery and replay. The rule is off until SECOC_ID is set. |
The allow-list rule is the quickest to demonstrate. List the identifiers your bus legitimately uses in VALID_IDS (for example 0x100, 0x110, 0x200), then run the Attacker in Spoof mode on an identifier outside that list to trip the alarm immediately.
Example
With an allow-list set and the freshness rule pointed at the secure engine message, run the Attacker through each mode in turn: Flood trips the flood rule, an out-of-list Spoof trips the unknown-identifier rule, and replaying the secure engine frame trips the freshness rule. Each shows in the popup and stores its own trouble code.
Authenticated Messaging (SecOC)
Secure Onboard Communication is the defence that makes a spoof or replay detectable. It adds two things to a protected frame: a freshness counter that increments on every transmission, and a message authentication code computed over the payload, the identifier and the counter using a shared secret key. A genuine sender can produce a valid code; an attacker who does not hold the key cannot, and a replayed frame carries an old counter. The protected eight-byte frame carries its payload in the first six bytes, the counter in byte 6 and the code in byte 7.
The Engine ECU is the genuine protected sender. Set its SECOC property to 1 and it emits an authenticated engine message, ENGINE_SECURE (0x141), alongside its normal traffic. Point the Intrusion Detection node's SECOC_ID at that identifier, with a matching SECOC_KEY, and it verifies every one. A frame from the genuine sender passes; a frame from the Attacker fails, because a spoof cannot forge the code and a replay repeats a spent counter.
The authentication code here is a fast keyed hash chosen for speed and clarity, not a cryptographic algorithm, and the key is a small shared constant. It demonstrates the principle of message authentication; it is not, and must not be used as, real protection.
Example
Run with the Engine ECU authenticating and the Attacker set to Replay on 0x141. The genuine frames verify silently; the moment the Attacker re-emits a captured frame, its counter is stale and the detector raises the freshness alarm. Contrast this with the same replay against an unprotected identifier, which goes undetected.
Access Control (UDS SecurityAccess)
The final stage controls access to a protected function rather than protecting a broadcast. It uses the standard diagnostic SecurityAccess service (UDS service 0x27), implemented by the Immobiliser node and available to a scan tool. A tester must prove it knows a shared secret before the ECU will unlock:
- The tester requests a seed (27 01).
- The ECU returns a four-byte seed (67 01 followed by the seed).
- The tester computes the key from the seed and sends it back (27 02 followed by the key).
- If the key is correct the ECU unlocks (67 02); if not, it returns a negative response and, after too many wrong keys, refuses further attempts for a lockout period.
In these models the key is the seed combined with a fixed mask by exclusive-or. The seed itself is set by the SEED property and is fixed by default, so the exchange is reproducible: a seed of A1B2C3D4 yields the key B38695AC. The negative responses follow the ISO 14229 convention, including sequence error if a key is sent before a seed is requested, invalid key, exceeded number of attempts, and time delay not expired during a lockout.
The weak exclusive-or transform is itself the teaching point. Because anyone who observes one seed-and-key pair can deduce the mask, it shows why a real implementation must use a strong, secret transform. Ask students to recover the mask from a single captured exchange.
Example
From the Scan Tool, request a seed from the Immobiliser, apply the mask to compute the key, and send it to unlock the node. Then send three deliberately wrong keys and watch the node enter its lockout, refusing further requests until the delay expires.
Security Message and Code Reference
The messages and codes specific to the security unit are summarised below. They extend the main Bus Message Map.
| Identifier | Message or code | Meaning |
|
0x141 |
ENGINE_SECURE | Authenticated engine data from the Engine ECU: payload, freshness counter and authentication code. |
|
0x180 |
IMMO_STATUS | Immobiliser state, which also hosts the UDS SecurityAccess exchange. |
|
0x250 |
IDS_ALERT | Broadcast by the Intrusion Detection node when a rule trips: the rule number, the offending identifier and a running alert count. |
|
U07A0 |
Unknown identifier | A rogue or spoofed identifier was seen on the bus. |
|
U07A1 |
Flood | Bus flooding or injection was detected. |
|
U07A2 |
Freshness | A forged or replayed authenticated frame was detected. |
See Also