Definition
An opaque identifier is one whose structure reveals nothing meaningful to the party that holds it. The recipient treats it as an unstructured string — they can store it, compare it, and reference it, but cannot derive any additional information from its content.
Opacity is a design property, not a cryptographic guarantee. An identifier can be unguessable (high entropy) but still non-opaque (the timestamp is readable). UUID v4 is both unguessable and opaque. UUID v7 is unguessable but semi-opaque — the creation timestamp is recoverable from the ID.
UUID v4 — fully opaque
UUID v4 consists entirely of cryptographic random bits (122 bits from a CSPRNG):
a8098c1a-f86e-4da4-bd1a-00112444be1e
An external party holding this ID cannot determine:
- When it was created
- How many IDs have been generated
- Which system generated it
- Any relationship to other IDs
UUID v4 is the right choice wherever the ID will be seen by untrusted parties and creation time must not be disclosed. The full specification is in RFC 9562 §5.4.
UUID v7 — semi-opaque
UUID v7 encodes a 48-bit Unix millisecond timestamp in its leading bits:
019236a7-b4f2-7000-8d3e-9c1a2b3d4e5f
^^^^^^^^^^^^^^^^^
Timestamp prefix: milliseconds since 1970-01-01T00:00:00Z
Any party holding a UUID v7 can extract the creation timestamp:
const uuid = '019236a7-b4f2-7000-8d3e-9c1a2b3d4e5f';
const tsMs = parseInt(uuid.replace(/-/g, '').slice(0, 12), 16);
console.log(new Date(tsMs).toISOString()); // "2026-09-25T16:00:00.000Z"
UUID v7 is appropriate for internal identifiers where creation time is not sensitive — database primary keys, event IDs, audit log entries. It is not appropriate for user account IDs in public URLs, API keys, or any ID where creation time reveals sensitive information about users or business activity.
Information leakage by ID type
| ID type | Reveals | To whom |
|---|---|---|
| Auto-increment integer | Total record count | Anyone who sees two IDs |
| UUID v1 | Creation time + MAC address | Anyone with the ID |
| UUID v7 | Creation timestamp (ms) | Anyone with the ID |
| UUID v4 | Nothing | N/A — fully opaque |
| NanoID | Nothing | N/A — fully opaque |
Auto-increment integers are the least opaque — id=10042 tells an attacker there are approximately 10,000 prior records, enabling enumeration attacks. UUID v7 is a significant improvement — the timestamp is recoverable but no count information leaks. UUID v4 is fully opaque.
Opacity in API design
A well-designed API uses different ID types for different purposes:
GET /users/a8098c1a-f86e-4da4-bd1a-00112444be1e ← UUID v4 (user ID in URL)
No creation time disclosed
GET /admin/users?after=019236a7-b4f2-7000-... ← UUID v7 (internal cursor)
Timestamp acceptable here
User-facing IDs in URLs should be UUID v4 or otherwise opaque — browsers record URLs in history, CDNs log them, and analytics tools capture them. Internal API endpoints used only by authenticated admin clients can safely use UUID v7 cursors where the timestamp is a feature.
Opacity vs unpredictability
These are related but distinct properties:
- Unpredictable: cannot be guessed or enumerated by an attacker
- Opaque: carries no decodable information even when held legitimately
UUID v4 is both. UUID v7 is unpredictable (74 random bits are sufficient to prevent guessing) but not fully opaque (the timestamp is recoverable). Auto-increment integers are predictable and non-opaque. Cryptographic tokens (32 random bytes) are unpredictable but may embed metadata — depends on format.
The OWASP Top 10 and the OWASP IDOR prevention cheat sheet cover the practical security implications of identifier design in web applications.
Related terms
- Entropy — the unpredictability of a UUID’s bits
- CSPRNG — the source of randomness in UUID v4
- Time-Ordered UUID — UUID v7 and the timestamp field
- UUID Security — full guide on UUID security properties
External references
- RFC 9562 — UUID standard
- OWASP Top 10
- OWASP IDOR Prevention Cheat Sheet
- OWASP Insecure Randomness
- Wikipedia — Universally unique identifier
Frequently asked questions
What makes a UUID opaque?
An opaque identifier is one whose internal structure carries no meaningful information to the party holding it. UUID v4 is opaque — 122 bits of cryptographic randomness from a CSPRNG reveal nothing about the system, user, or time that generated the ID. UUID v7 is semi-opaque — it carries a 48-bit millisecond timestamp that discloses creation time to anyone who holds the ID. The RFC 9562 standard defines both formats; the choice between them is a privacy design decision.
Why does opacity matter for identifiers in URLs?
Identifiers in URLs appear in browser history, server logs, referrer headers, CDN access logs, and analytics tools. A non-opaque ID in a URL leaks information to anyone with log access. UUID v7 in a public URL reveals when the resource was created. Sequential integers reveal the total number of resources. UUID v4 — fully opaque — reveals nothing beyond the existence of the resource. The OWASP Top 10 A01 Broken Access Control explicitly covers insecure direct object references and the risks of predictable or information-leaking IDs.
Is UUID v4 safe to use as a capability token?
No. A UUID v4 is an identifier, not a secret. Identifiers appear in logs, URLs, error messages, and browser history. A capability token needs to be both unguessable and unexposed — treat it like a password. Use 256-bit random bytes from a CSPRNG (e.g. crypto.randomBytes(32).toString('hex') in Node.js) stored as a hash server-side. The OWASP Insecure Randomness page and the OWASP Session Management Cheat Sheet cover token entropy requirements.