Embedded Garage

UDS SecurityAccess (0x27), byte by byte

SecurityAccess is the lock in front of the services that can change an ECU. The exchange is four short messages, and most of the trouble comes from the rules around them, not from the messages themselves.

By Sanket S. Shahane, 13 November 2026. All notes

What it is for

An ECU will read out most data to anyone who asks. Writing data, running routines and downloading new software are different: ISO 14229-1 lets the ECU keep those behind a lock. SecurityAccess, service 0x27, is how a tester opens that lock. It is a challenge and response. The ECU sends a random number, the seed. The tester computes a key from it with an algorithm both sides know, and sends the key back. If it matches, the ECU unlocks.

The exchange

Here is a complete unlock for security level 1, with a four-byte seed and key. The length of the seed and key is chosen by the manufacturer, so four bytes is only an example.

DirectionBytesMeaning
Tester to ECU27 01Request seed, level 1
ECU to tester67 01 A1 B2 C3 D4Positive response with the seed
Tester to ECU27 02 5E 4D 3C 2BSend key, level 1
ECU to tester67 02Key accepted, ECU unlocked

A positive response always starts with the service identifier plus 0x40, so 0x27 is answered with 0x67, followed by the sub-function that was requested.

How the sub-functions are numbered

Each security level uses a pair of sub-functions. The odd number requests the seed and the next even number sends the key. Level 1 is 0x01 and 0x02, the next level is 0x03 and 0x04, and so on. Which level protects which services is decided by the manufacturer. A common mistake in a first implementation is to treat 0x02 as a second level, when it is the second half of the first.

When it goes wrong

A refusal is a negative response: 0x7F, then the service that was refused, then one negative response code. A wrong key for this service comes back as 7F 27 35. These are the codes you will meet most with SecurityAccess.

CodeNameUsual cause
0x12Sub-function not supportedThat security level does not exist in this ECU
0x13Incorrect message lengthThe key has the wrong number of bytes
0x22Conditions not correctThe ECU is not in a state where it will unlock
0x24Request sequence errorA key was sent without asking for a seed first
0x35Invalid keyThe key does not match the seed
0x36Exceeded number of attemptsToo many wrong keys in a row
0x37Required time delay not expiredThe ECU is still in its lock-out delay
0x7FService not supported in active sessionThe ECU is still in the default session

The rules that catch people out

  • Change session first. Most ECUs refuse SecurityAccess in the default session. Send DiagnosticSessionControl (0x10) to enter the extended or programming session, then ask for the seed.
  • A seed of all zeros means "already unlocked". If the level is open, the ECU answers the seed request with zeros. The tester must not compute and send a key for it.
  • The seed is single use. A key is only valid for the seed that was just issued. Ask for a new seed and the old one is gone.
  • Wrong keys are counted. After the allowed number of failed attempts the ECU answers 0x36 and starts a delay timer. Every request during that delay gets 0x37. Retrying quickly in a loop only keeps you locked out.
  • The delay can also run at power-up. Some ECUs start the timer every time they boot, so that power cycling cannot be used to reset the attempt counter. If the first seed request after power-on returns 0x37, wait and try again before suspecting your code.
  • The lock closes again. When the session times out and the ECU falls back to the default session, it locks. Keep sending TesterPresent (0x3E) while you work.
  • Long seeds and keys need ISO-TP. Anything that does not fit in a single CAN frame is sent as a multi-frame message. The ISO-TP instrument shows how that is split.

On the ECU side

If you are writing the server, three states are enough: locked, seed issued, and unlocked. A key is only accepted in the seed-issued state, which is what produces the 0x24 sequence error for free. Beyond that:

  • Generate the seed from a real random source. A constant or counting seed lets anyone replay a recorded unlock.
  • Never issue a seed of zero while locked, because zero has a meaning of its own.
  • Keep the failed-attempt counter in non-volatile memory, or start the delay at boot. Otherwise a power cycle resets the protection.
  • Check the message length before you look at the key, and answer 0x13 if it is wrong.

A short checklist

When an unlock fails, read the negative response code before changing anything. 0x7F points at the session, 0x24 at the order of your requests, 0x35 at the algorithm or the byte order of the key, and 0x37 at nothing more than time.