UUID security considerations - cover art

Comparisons 15 min read

UUID security considerations

November 15, 2026 · 15 min read

UUIDs are identifiers, not access control. Version 4 random UUIDs make guessing hard, but they do not replace authentication, authorization, or rate limits. Security reviews should treat public UUIDs like usernames: opaque, not secret, still needing permission checks on every operation.

Version 4 randomness

Use CSPRNG-backed v4 (or v7 with random components) for tokens exposed externally. Predictable PRNGs or hand-rolled hex defeat the purpose. Validate partner-supplied UUIDs - never trust client-generated ids without ownership proof on create.

Don't leak order with sequential or v1 UUIDs

Sequential integers and some time-based UUIDs reveal creation order and sometimes machine hints. v1 embeds MAC-derived node identifiers in legacy deployments. Prefer v4/v7 for public resource ids when enumeration timing matters competitively.

Authorization beats obscurity

Knowing orderId must not grant download of invoices. Enforce policy server-side keyed by authenticated sub, not by guessing opaque ids. Pair UUID resources with session or JWT scopes.

Exposure in URLs, referrers, and logs

UUIDs in shareable links leak via email and analytics. Rotate resource tokens when sharing is revoked. Redact ids in public error messages if combined with weak secondary checks.

Storage and validation hygiene

Normalize to canonical string form at the boundary. Use UUID validator in tests. For MongoDB binary storage, avoid endianness bugs that cause wrong-record lookups - a data integrity issue with security impact.

FAQ

Are UUIDs unguessable?
v4 with proper RNG makes brute force infeasible for 122 random bits; authorization is still mandatory.
Should I use UUID as session token?
Use long random bytes (256+ bits) designed for secrets; UUID v4 is borderline short for session secrets alone.
Is UUID v5 secure for URLs?
v5 is deterministic from namespace+name - not secret. Fine for stable derived keys, not for capability URLs.

Related: UUIDs in REST APIs · Sequential UUIDs · Common UUID mistakes · How to generate secure UUIDs

Browse all tools