ECU Firmware Analysis
An ECU image is where the access control you met over diagnostics is actually implemented. This page covers acquiring one, identifying what it contains, establishing the address it was linked for, and getting from a byte offset to a routine that can be written up as a finding.
Firmware Acquisition
There are four practical sources, in ascending order of intrusiveness. OEM update files are the easiest: many manufacturers publish service updates as downloadable bundles, and an over-the-air package captured from the vehicle's own update client is the same image with less work. Update media — a USB stick or SD card used by a dealer — exposes the signed bundle and the update manifest. Reading over UDS uses the diagnostic path, service 0x23 (ReadMemoryByAddress) and the older 0x35 (RequestUpload), subject to the gate chain below. And direct chip access (JTAG/SWD with a J-Link, ST-Link, Bus Pirate, or ChipWhisperer) is the fallback when the firmware is read-protected at the debug interface.
Knowing the processor narrows the toolchain: Renesas RH850, Infineon TriCore, NXP MPC5xxx, and ARM Cortex parts each need the right architecture selected in the disassembler before a single function makes sense. UN Regulation No. 156 is worth reading alongside this page — it makes the software update management system, and therefore the signing and rollback behaviour you are about to attack, part of type approval.
The routes differ in which gate they meet, so which route produced an image decides what the acquisition proves.
What Gates A Memory Read
Reading memory over diagnostics is the last step of a chain, and every step can refuse. The refusals are worth more than a success, because each one names a different control.
-
Session.
0x10 0x03opens the extended diagnostic session that usually carries a memory read;0x10 0x02opens programming for the transfer services. From the default session the answer is7F <service> 7F, serviceNotSupportedInActiveSession. -
Unlock. SecurityAccess
0x27at the level the service requires, or Authentication0x29where the platform implements it. Without it the answer is7F <service> 33, securityAccessDenied. -
Read.
0x23with an address-and-length format identifier, or0x35followed by repeated0x36TransferData for each block, on the platforms that still keep the upload pair.
The negative response is three bytes: 0x7F, the service that was refused, then one NRC. That third byte is the diagnosis — 0x7F is the wrong session, 0x33 a gate that is not open, 0x34 a missing authentication step, 0x31 an address or length the module does not expose even when unlocked, 0x22 a vehicle state it will not read in, 0x13 a malformed format identifier.
A completed 0x27 followed by a memory read is not a broken cipher. The seed-to-key algorithm was in the image you were able to read, which means the gate was recoverable by design — a fixed seed, a key equal to the seed, or a short table-driven transform. That is an access-control finding. The converse matters as much: a refused 0x27 does not prove the image is protected, because a bundle, a boot-mode strap or a debug probe never passes through that service.
0x35 is the read direction of the pair whose write direction is 0x34 RequestDownload. It is the older service, many ECUs answer 0x11 serviceNotSupported to it, and where it survives the data arrives in 0x36 blocks sized by the 0x75 response.
# ReadMemoryByAddress (0x23) over ISO-TP, physical addressing 0x7E0 request / 0x7E8 response.
# The ALFID is one byte: high nibble = length of the size field, low nibble = length of
# the address field. 0x24 therefore means a 4-byte address and a 2-byte size.
Request : 10 03 # extended diagnostic session
Response: 50 03 00 32 01 F4 # P2 = 50 ms, P2* = 5000 ms
Request : 27 01 # SecurityAccess, request seed, level 1
Response: 67 01 5A 3C 91 02 # seed; one that repeats across resets is the finding
Request : 27 02 3F 7A B1 88 # key derived from that seed by the OEM routine
Response: 67 02
# 0x23 <ALFID> <address, 4 bytes> <size, 2 bytes> is 8 bytes, so ISO-TP carries it
# as a First Frame plus one Consecutive Frame on classical CAN.
Request : 23 24 00 00 00 00 00 40 # read 0x40 bytes at 0x00000000
Response: 63 00 20 00 08 ... # 0x63 then the data; multi-frame, SN 0x21 onward.
# Illustrative: first two words are the initial SP
# and the reset vector of an ARM image.
# Refusals are three bytes: 0x7F, the refused service, then the NRC.
Response: 7F 23 33 # 0x33 securityAccessDenied
Response: 7F 23 31 # 0x31 requestOutOfRange
Response: 7F 23 7F # 0x7F serviceNotSupportedInActiveSessionWhat An Image Actually Contains
An ECU image is rarely a flat block of code. It is usually a container: a bootloader, an application, calibration
data, sometimes a filesystem. binwalk
exists to tell you where the boundaries are, and its output is a list of offsets in which every line is a
byte-pattern match.
binwalk ecu_application.bin
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
0 0x0 ARM executable code, 32-bit (little endian)
64 0x40 uImage header, header size: 64 bytes, image size: 483328 bytes,
Data Address: 0x08008000, Entry Point: 0x08008000, name: "Linux-4.19"
483392 0x76040 Squashfs filesystem, little endian, version 4.0, compression: xz,
size: 12042240 bytes, 1204 inodes, blocksize: 131072 bytes
8601600 0x834000 gzip compressed data, maximum compression, from Unix
12536832 0xBF4C00 Certificate in DER format (x509 v3), header length: 4, sequence length: 948Read the list rather than the count. An ARM hit at offset 0 with no container above it means a raw image, and the first two words are the stack pointer and reset vector. A uImage header names the load address and entry point outright — the base address handed to you — and its payload starts 64 bytes in. A squashfs, cramfs, jffs2 or UBI hit is a filesystem, and a filesystem is where configuration, startup scripts and key material stored as files live. A gzip hit is usually a compressed region inside something else, so extracting it yields a smaller image to scan again. The certificate hit matters in the trust-anchor section below.
A hit is a candidate, not a finding. Every signature is a short magic number, and compressed or encrypted data matches a four-byte pattern by chance often enough to matter. Two checks settle most of them: extract the region and identify the result, and confirm the declared size fits inside the file — a filesystem claiming 12 MB at an offset in a 4 MB image is a false positive by arithmetic. Hash the image as acquired, not the extraction directory.
Establishing The Load Address
Disassembly is only meaningful once you know the address the image was linked for. A disassembler will happily decode from zero; the question is whether a branch target lands on a function or in the middle of one.
- The vector table. On ARM the first two words are the initial stack pointer and the reset handler. The pointer is a RAM address near the top of SRAM, the handler a flash address, so the pair constrains the base before you read anything else. A handler with bit 0 set is a Thumb address.
- The 0x23 address echo. If the module lets you read memory, read the same bytes at 0x00000000 and at the candidate base. Identical content at two addresses is an alias, and the vector table appearing at the address the datasheet calls flash confirms the map.
- Linker remnants. Section names, build paths, toolchain strings and any surviving symbol table name the layout directly. The vector table's alignment is a second constraint: it sits on a boundary the linker chose.
- A cross-reference to a known routine. The UDS service dispatch is an array of handler pointers indexed by service identifier. If the entry for 0x27 resolves to the seed routine at your base, the base is right.
A wrong base produces plausible garbage rather than an obvious failure. Thumb-2 is dense enough that most 16-bit patterns decode as some instruction, PC-relative loads resolve to wrong but printable addresses, and strings are just bytes, so they still appear at their offsets. The listing therefore looks like a program. The symptoms are indirect: no cross-reference reaches a string you know is used, functions fall through into each other, branch targets land outside the memory map. Pick a string the code must reference and find the instruction that loads its address.
Analysis Process
# Identify firmware format
binwalk firmware.bin
file firmware.bin
strings firmware.bin | head -100
# Extract embedded files
binwalk -e firmware.bin
# Look in the disassembly for:
# - Security Access (0x27) seed algorithms
# - Encryption keys and signature checks
# - Debug interface enable flags
# - UDS service handlers and CAN message handlersWith the base established, work from the dispatch table outward: its 0x27 entry leads to the seed generator and key comparison, and the comparison leads to the transform — often an XOR with a constant, a lookup table, or a short linear calculation. Once recovered, the protected services open without any exploit. Check the routine against a seed observed on the vehicle; that comparison turns a decompiled function into a finding, and a fixed seed or table-driven key is a design flaw, not an implementation bug.
Security Access (0x27) is no longer the only gate. ISO 14229-1:2020 added service 0x29 (Authentication), a certificate-based exchange in which the tester presents a certificate and proves possession of the matching private key; the current edition is ISO 14229-1:2026, and an ECU may implement 0x29 instead of, or alongside, seed-and-key. Look for both handlers before concluding that an ECU has no access control at all. The service-level detail of 0x10, 0x27 and 0x29 is on Diagnostics.
Processor Databases
Where The 0x29 Trust Anchor Sits
Authentication is certificate-based, so the ECU has to hold something it trusts: a public key, a hash of one, or a reference into secure storage. That anchor is what the certificate chain is validated against, and it has to be present in whatever component performs the check.
-
Software verification on the application core. The anchor is in the image: a DER certificate, a
raw public key, or a 32-byte hash.
binwalkmay flag a DER certificate; a raw key is flagged by nothing, so search by size and structure around the verification code instead. - An HSM or secure element. The key stays in secure storage and the image holds only an identifier for it. The absence of a key blob is not the absence of a check.
- The bootloader. Verification often runs before the application starts, in a separate image from the same bundle. Finding no check in the application may mean you are holding the wrong image.
Finding the anchor is a different job from defeating it. Identifying it tells you what the ECU trusts; defeating it means finding a flaw in the verification — a length check that is missing, a hash compared against a writable copy, a downgrade path that skips the check — or replacing the anchor, which needs write access the signature exists to prevent. Report those as two findings: the anchor at an offset, and the specific way the check fails. "Signing is broken" is a conclusion neither of them supports on its own.
Evidence Collection
A firmware claim is only checkable if the next analyst can obtain the same bytes and land on the same routine. Record:
Image identity: Part number, software version and variant, as the ECU or the bundle states them. Two images from one family differ by these fields before they differ by a byte.
Source and acquisition path:
Which of the four routes produced the image — OEM bundle, dealer update media, 0x23 or 0x35 over UDS, or a JTAG/SWD dump — with the tool and adapter used.
Byte length and SHA-256:
Of the file as acquired, before any extraction or patching. binwalk -e writes new files, and their hashes are not the image hash.
Processor, endianness and load address: What the disassembler was told, and how the base address was established, usually the pointer table near the reset vector. A wrong base produces plausible nonsense that survives review.
Offsets for every claim: For each recovered routine or key, the offset and length within the image, so the next analyst lands on the same bytes rather than repeating the hunt.
Confirmed against the vehicle: Whether the recovered seed-to-key routine reproduces a seed observed over diagnostics. That comparison turns a decompiled function into a finding.
False Positive Identification
- A key-shaped string that is a build tag: Version strings, compiler paths and test vectors read as secrets. Check that a routine actually consumes the bytes before reporting them as key material.
- The wrong image from a bundle: A bootloader, a calibration block and the application are separate images. Record which one the hash belongs to and which one the ECU boots.
- A decompiler artefact: An unresolved indirect call or a check that appears to be missing is often the decompiler rather than the firmware. Confirm in the disassembly before writing it up.
- A routine that only looks like the seed algorithm: Diagnostic log formatters and checksum helpers sit near the 0x27 handler. Reproduce a seed with it, or describe it as unconfirmed.
- A delta or a container: A patch file or update container hashes to something that is not the installed image. Verify the assembled result against the target hash the manifest names.
- A module that arrived unlocked: A unit delivered in a development or end-of-line state answers protected services without any key. State the state it arrived in, or the finding is attribution.
Acquisition And Attribution Checklist
The path above, in the order it is run. The acquisition and the attribution are separate records and are checked separately.
Acquire
- ☐ Record the route and the gate passed to use it: the session, the 0x27 level, or the 0x29 role.
- ☐ Keep the image as acquired, with its byte length and SHA-256, before binwalk or any extraction.
- ☐ Record part number, software version and variant from the ECU or the bundle, and which image in the bundle it is.
- ☐ Note the module state the acquisition met — production, development or end-of-line — because it changes what a successful read proves.
Establish the base
- ☐ Read the first eight bytes and check the vector pair against the memory map before disassembling anything.
- ☐ Confirm the base with a cross-reference — a known string load or the service dispatch entry for
0x27— not with a listing that merely looks plausible. - ☐ Record processor, endianness, load address and the evidence that produced the address.
- ☐ Re-check the base after any extraction: offsets inside an extracted filesystem are relative to that filesystem, not to the image.
Attribute a finding
- ☐ Give every key, signature check or seed routine an offset and a length within the image as acquired.
- ☐ Reproduce a seed observed on the vehicle with the recovered routine before calling it the 0x27 algorithm.
- ☐ Say whether verification lives in the application, the bootloader or an HSM, and name the image you actually hold.
Remediation
The access-control findings on this page are one software class plus a design decision about the seed.
Key material
- • Derive the seed-to-key secret per ECU from material in secure storage rather than a constant embedded in the image.
- • Remove test keys, debug flags and development credentials from production images, and treat one left behind as the finding even before a key is recovered.
The exchange
- • Randomise the seed per request: a fixed seed makes the strength of the algorithm irrelevant.
- • Avoid a short XOR or a small lookup table as the whole transform, and pair 0x27 with 0x29 where the platform can support certificate-based authentication.
CWE References: CWE-798