RFC 4122: UUIDs: Unique identifiers without central allocation
Summary
In July 2005, Paul Leach, Michael Mealling and Rich Salz standardised Universally Unique Identifiers in RFC 4122, 128-bit identifiers meant to be globally unique without a central allocation authority. The document adopts the format from the Distributed Computing Environment and describes variants based on time and MAC address, names with a hash, or randomness. RFC 9562 replaced it in May 2024 and added, among other things, the time-sortable version 7.
Unique without coordination
A UUID consists of 128 bits, written as 32 hexadecimal digits in five groups. Some bits indicate variant and version. Version 1 combines a timestamp in 100-nanosecond steps since 15 October 1582, the day of the Gregorian calendar reform, with the MAC address. Versions 3 and 5 hash a name with MD5 or SHA-1, and version 4 is random.
The idea comes from the Apollo Network Computing System and the Open Software Foundation’s Distributed Computing Environment. Microsoft uses the same format as GUID.
What UUIDs are not
RFC 4122 warns explicitly not to assume that UUIDs are hard to guess and not to use them as security capabilities. Version 1 also reveals the MAC address and time of creation.
In databases, random version 4 UUIDs as primary keys have a drawback: new entries land scattered throughout the index instead of at the end. RFC 9562 therefore introduced version 7, which starts with a Unix timestamp in milliseconds and is thus sorted by creation.
Ideas
- 128 bits suffice for globally unique identifiers without a central authority.
- The version indicates how a UUID was generated.
- Version 1 combines a timestamp and the MAC address.
- Versions 3 and 5 derive UUIDs reproducibly from names.
- Version 4 consists mostly of randomness.
- UUIDs are no protection against guessing.
Insights
- Decentralised identifiers decouple systems from one another but bring their own questions about privacy and sorting.
- An identifier format must fit its use; choosing the right version is an architectural decision.
Facts
- RFC 4122 appeared in July 2005 and was replaced by RFC 9562 in May 2024.
- Version 1 timestamps count 100-nanosecond steps since 15 October 1582.
- Version 3 uses MD5, version 5 SHA-1.
- RFC 9562 adds versions 6, 7 and 8 as well as the Max UUID.
References
- RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace
- RFC 9562: Universally Unique IDentifiers (UUIDs) (2024)
Remarks
- The WebSocket specification RFC 6455 uses a fixed UUID as a magic value in the handshake.
Recommendations
- Prefer UUID version 7 for database keys if the library supports it.
- For secret tokens, use cryptographically random values of sufficient length rather than UUIDs.
- Avoid version 1 if the MAC address and time should not be revealed.
Read the RFC at the RFC Editor
Found a mistake or have something to add? Get in touch.
Links to the original source and the Web Archive open in a new tab.