News for hackers. Stuff that matters.
Re:New UUID Formats – IETF Draft by pjscott on Friday August 06, 2021 @01:07PM (#28090022)
A somewhat oversimplified summary of the new UUID formats:

UUID6: a timestamp with a weird epoch and 100 ns precision like in UUID1, but in a big-endian order that sorts naturally by time, plus some random bits instead of a predictable MAC address.

UUID7: like UUID6, but uses normal Unix timestamps and allows more timestamp precision.

UUID8: like UUID7, but relaxes requirements on where the timestamp is coming from. Want to use a custom epoch or NTP timestamps or something? UUID8 allows it for the sake of flexibility and future-proofing, but the downside is that there's no standard way to parse the time from one of these -- the time source could be anything monotonic.

Re:New UUID Formats – IETF Draft by phkahler on Friday August 06, 2021 @05:05PM (#28092737)
>> but the downside is that there's no standard way to parse the time from one of these

IMHO that should not be a concern. The goal of UUID is to create a Unique Identifier, not to record the time something was created. Maybe we should all have quantum random number generators, but with that I don't think 128 bits is enough for a UUID. Might be enough for specific applications though.

First rule of database design: Your unique IDs should not have a real-world meaning.

Re:New UUID Formats – IETF Draft by mulmen on Friday August 06, 2021 @05:38PM (#28093055)
> First rule of database design: Your unique IDs should not have a real-world meaning.

Well, this is an opinion. I would definitely push back on making it a rule. Especially the first one.

Natural keys exist, make perfectly good unique identifiers, and have inherent meaning.

When using synthetic keys it is difficult (read: requires making trade-offs) to guarantee they were created in order and/or that they increase monotonically. But if you make those trade-offs (or just align expectations) you can still associate real world meaning to them.

These new UUIDs standardize more of those trade-offs.

Re:New UUID Formats – IETF Draft by tialaramex on Friday August 06, 2021 @10:24PM (#28095111)
> Natural keys exist, make perfectly good unique identifiers, and have inherent meaning.

Most of the "natural" things you think are going to be good Primary Keys aren't. You quickly get into one of those "Falsehoods Programmers Believe About X" lists.

I remember some years ago running into the Experian team who were designing a system to uniquely identify people and they'd got it all figured out for the US market. See, Americans have Social Security Numbers, so you can just use those to key off. Alas, as hopefully anybody here who actually deals with Social Security Numbers knows, they aren't unique. Perhaps you could argue they should be unique, but that's not useful in practice, because in practice they aren't. They seemed really disappointed about that. I doubt they fixed it though.

It's far more likely that the "definitely unique" Natural key for your table isn't actually unique than that there will be an insurmountable problem caused by using artificial row IDs, UUIDs or something like that.

Re:New UUID Formats – IETF Draft by _moof on Saturday August 07, 2021 @01:46PM (#28100405)
SSNs can also change.

Never, ever, ever try to use SSN as a primary key or anything even remotely like a primary key.

Re:New UUID Formats – IETF Draft by rkagerer on Friday August 06, 2021 @11:53PM (#28095537)
SSN is a terrible key (and given privacy and security concerns should probably be encrypted or otherwise peotected in any case, not showing up in logs, developers notes while troubleshooting, etc).

Product serial number might be a better example. Or file hash.

Re:New UUID Formats – IETF Draft by tialaramex on Saturday August 07, 2021 @08:05AM (#28097949)
> Product serial number might be a better example.

Nope. The "serial number" is just whatever you printed on the box or maybe on the product itself. You may intend that to be unique but you've got no way to ensure that. If you tell the people in manufacturing that if any duplicates occur it's a show stopper they will tell you to stop being stupid and design your IT systems to cope with the real world.

I buy serial-numbered LED lamps, the manufacturer replaces them if they drop dead within a certain number of years and I have some applications (18 hours per day of lighting) where that's plausible, so I need to track those serial numbers. Except they once shipped me a lamp (one in a box purchased together with others) with no serial number. Completely blank, no manufacturer, no type identifier, no voltage, the entire label was just missing from the product as shipped. Emailed them. No problem, apologies for the defect, your warranty registration for a lamp with no serial number will be fine.

Re:New UUID Formats – IETF Draft by michaelt on Saturday August 07, 2021 @09:21AM (#28098399)
> If you tell the people in manufacturing that if any duplicates occur it's a show stopper they will tell you to stop being stupid and design your IT systems to cope with the real world.

You've got a pretty low opinion of people in manufacturing there, buddy.

No manufacturer I've ever worked with would even blink at a requirement for unique serial numbers.

Re:New UUID Formats – IETF Draft by tialaramex on Saturday August 07, 2021 @10:29AM (#28098825)
> No manufacturer I've ever worked with would even blink at a requirement for unique serial numbers.

It's easy and even expected to have a requirement. There's a requirement that US SSNs are unique too. A requirement doesn't cut it. The requirement is going to fail sooner or later and what then? How much did the manufacturers you worked with indemnify you against the consequences of non-unique serial numbers?

That's what we're getting at here. When it breaks somebody has to fix it. Or, you could design it not to break.

It's a man's laws versus nature's laws problem. Did you know you can pick up the soccer ball, and just carry it over the goal line? Yeah, that's "against the rules" but you can do it anyway, being against the rules doesn't make it impossible.

Now, contrariwise you can't teleport the ball - doesn't matter whether the rules allow it, can't do it anyway. Nature's law are facts. Design your database to rely on facts, not man's laws as much as possible.

Re:New UUID Formats – IETF Draft by mulmen on Saturday August 07, 2021 @11:22AM (#28099231)
So Ford builds two F-150s with serial number 1234. One has internal_db_id 1 and the other has internal_db_id 2. I buy an F-150 with serial number 1234 and immediately smash it into a tree. Total loss.

You buy the other F-150 sn 1234. You take your truck in for service. They refuse to service salvage title vehicles under warranty. You explain you don’t have a salvage title. They blame “the system”. Your insurance company fares no better.

Or, Ford could put a unique constraint on serial number and catch the problem in the factory.

It’s not clear to me how the internal_db_id did anything except propagate an error until it was way too late to fix.

The entire point of properly modeling data is to codify and enforce the “rules”.

> Nature's law are facts. Design your database to rely on facts, not man's laws as much as possible.

Exactly. Natural keys can, along with normalization and constraints, stop you from picking up the ball and walking into the goal. In other words, natural keys define the nature of your system.

Re:New UUID Formats – IETF Draft by michaelt on Saturday August 07, 2021 @04:12PM (#28101440)
> The requirement is going to fail sooner or later and what then?

First of all it'll get picked up by the people who set up the serial number printer. They don't just set it to a random number - the factory will have a procedure to make sure the number is set right.

Then it'll get picked up by the end-of-line testing, as test reports are filed by serial number.

Then it'll get picked up when the first part comes off the production line and gets checked by the factory's most conscientious testers and engineers.

Then it'll get picked up at goods inbound, when they count the items and check them in, and find the system says some of them are used, or there's a discrepancy in the number of items.

Then it'll get picked up at acceptance testing, when they find the shipment's test records aren't in order.

Then it'll get picked up by accounts payable, when the manufacturer bills for parts they've already been paid for.

Then depending on the numbers and costs involved, you either send the bad units back for relabelling or trash them, in either case at the manufacturer's expense.

Re:New UUID Formats – IETF Draft by inetknght on Saturday August 07, 2021 @08:14PM (#28103071)
> First of all it'll get picked up by the people who set up the serial number printer. They don't just set it to a random number - the factory will have a procedure to make sure the number is set right.

Printer ran out of toner and nobody noticed until the next shift.

> Then it'll get picked up by the end-of-line testing, as test reports are filed by serial number.

Nah, test report operator was out sick that day and product needed to be pushed anyway. Manager assumed they're all good and overrode tests.

> Then it'll get picked up when the first part comes off the production line and gets checked by the factory's most conscientious testers and engineers.

Those testers and engineers don't have all day to test every single product. They only tested the first 100.

> Then it'll get picked up at goods inbound, when they count the items and check them in, and find the system says some of them are used, or there's a discrepancy in the number of items.

Counted by total weight divided by individual weight.

> Then it'll get picked up at acceptance testing, when they find the shipment's test records aren't in order.

Counted total number of UPCs.

> Then it'll get picked up by accounts payable, when the manufacturer bills for parts they've already been paid for.

Accounts payable sees a box, of 1000 parts and they're labeled and the top 100 appear genuine... pay it.

> Then depending on the numbers and costs involved, you either send the bad units back for relabelling or trash them, in either case at the manufacturer's expense.

Manufacturer thinks you're trying to defraud them and won't authorize a return without a serial number.

Re:New UUID Formats – IETF Draft by michaelt on Sunday August 08, 2021 @06:17AM (#28105621)
I'm guessing you've never worked in manufacturing for a product with a serial number?

The whole point of a serial number is to be able to track an item through your supply chain

If it can get through your supply chain without anyone ever reading the serial number, why are you putting a serial number on it at all? Decoration?

Re:New UUID Formats – IETF Draft by inetknght on Sunday August 08, 2021 @09:53AM (#28106705)
I have, in fact, worked for multiple manufacturers of serialized products.

My point is that even though there are multiple points where the serial number "should" be checked, there are also multiple points where that could fail for one reason or another.

Re:New UUID Formats – IETF Draft by staticassertion on Saturday August 07, 2021 @09:29AM (#28098437)
I mean, they said "might be", and they're entirely correct about SSN.

> Emailed them. No problem, apologies for the defect, your warranty registration for a lamp with no serial number will be fine.

Seems fine?

Re:New UUID Formats – IETF Draft by williamdclt on Saturday August 07, 2021 @06:47AM (#28097557)
> Natural keys exist

They probably do, but everytime I thought something was good as a natural key, I've been wrong

Re:New UUID Formats – IETF Draft by phkahler on Monday August 09, 2021 @09:31AM (#28116540)
Agreed. The simplest example is names. People don't have unique names so you combine it with some other stuff (birthdate, SSN) and call it a primary key. Then someone gets married and changes their name. To anyone doing this for a short amount of time this example is obvious. The point is that almost everything you might think of as a "natural key" is not good enough and you'll get burned when you find out what the reasons are.
Re:New UUID Formats – IETF Draft by koolba on Friday August 06, 2021 @06:10PM (#28093349)
In theory, theory and practice are the same. In practice they’re not.

Sortable unique IDs have many performance benefits in real world systems.

Re:New UUID Formats – IETF Draft by lonjil on Friday August 13, 2021 @08:01AM (#28167863)
Just put an index on whatever nice sortable unique field you happen to have, then?
Re:New UUID Formats – IETF Draft by iratewizard on Friday August 06, 2021 @06:35PM (#28093564)
> First rule of database design: Your unique IDs should not have a real-world meaning.

I see a lot of comments conflating a unique ID with a unique column. It's OK for you to have a unique contraint on something like an email column. But you wouldn't use the email column as the primary key.

Re:New UUID Formats – IETF Draft by remram on Friday August 06, 2021 @07:31PM (#28094027)
If that's how you feel about it, why use UUID at all? You could use any 16 bytes and not format them according to any standard.
Re:New UUID Formats – IETF Draft by voidnullnil on Monday August 09, 2021 @03:55PM (#28121603)
To take this one step further: Adding surprise semantics like capturing time (and the dev not being aware of it) will lead to security vulnerabilities (side channels because the code is essentially timestamping when various parts of the code are hit) as well as privacy issues (PII leaking, clock skew leaking, whatever).

My thesis is that computers are so full of unwanted unneeded things like this that there is no engineer who knows them all as well as having a good understanding software engineering as well as infosec. Most vulnerabilities are due to lack of understanding how the primitives work, as opposed to flaws in reasoning (the former is clearly distinct: the summary provided to save him from spending a month looking at the implementation is inadequate).

I have designed UUIDs myself and they are simply a long random bitstring. The random part is already necessary because we need sufficient randomness for crypto to work in the first place. IETF likes to "engineer" things.

Re:New UUID Formats – IETF Draft by ryanisnan on Saturday August 07, 2021 @01:00AM (#28095841)
> to record the time something was created.

I don't think that was the downside mentioned, I think it was because of the lack of standardization on how to parse the timestamp.

Re:New UUID Formats – IETF Draft by wilg on Friday August 06, 2021 @06:20PM (#28093434)
If you don't think that's a concern then UUID8 is for you!
Re:New UUID Formats – IETF Draft by zvrba on Friday August 06, 2021 @01:22PM (#28090252)
> with a weird epoch and 100 ns precision

Exactly as used by windows to store file times. And the epoch is the start of the modern calendar https://en.wikipedia.org/wiki/Gregorian_calendar

Talking about dates before this epoch makes little sense (any date before the Gregorian epoch will not resemble the same stellar / planet constellation as date after the Gregorian epoch).

Re:New UUID Formats – IETF Draft by pjscott on Friday August 06, 2021 @02:02PM (#28090796)
A precision of 100 ns is not bad, just inflexible; I didn't mean to imply otherwise. The epoch is weird, though. Here's a thought experiment: imagine that a hundred programmers are each asked to pick an epoch for a timestamp, and will be paid $1000 for each other programmer who chooses the same epoch, but they can't talk with each other to coordinate. Which would you pick? I would pick the Unix epoch, because I think others would do the same. Anything else is, in a certain important sense, weird.
Re:New UUID Formats – IETF Draft by ericb on Friday August 06, 2021 @02:28PM (#28091115)
This is a great example of a Schelling Point!

I'd also argue that you're right, and that as a principle, good UI/UX and software architecture should default to following natural Schelling Points.

Re:New UUID Formats – IETF Draft by FactolSarin on Friday August 06, 2021 @06:06PM (#28093304)
That doesn't make the epoch weird, just different. The Unix Epoch is itself weird. I personally like it mostly for being a neat little historical artifact, but it's not interesting in any sense. What epoch would your hypothetical programmers settle on if they all had their minds wiped of any existing epochs.

I bet you'd see a lot of Jan 1 1900, 2000, or year 1. Very few would pick 1970.

Other fun non-Jan 1 ideas might be December 26, 1791 (Charles Babbage's birthday) or February 5, 1944, (the date Colossus came online)

Re:New UUID Formats – IETF Draft by mjevans on Friday August 06, 2021 @07:23PM (#28093946)
It makes a great deal of sense when thinking about the use case: recording a monotinic time in a computing environment with limited resources and extremely unlikely to ever see files from before midnight of new years eve 1970.

With a great deal of existing routines that work with those values and a good number of existing files and storage applications based on the simple version, it makes even mores sense to extend that in an unsigned way with a larger bitfield for any timestamp. Though as recently came up, leap seconds and synchronization could use a few bits to describe which timestamp is in use.

Re:New UUID Formats – IETF Draft by bombcar on Friday August 06, 2021 @07:01PM (#28093761)
1970 makes sense if you’re picking an epoch and you are in the 70s - everything will happen “after” your start date but picking the actual current date doesn’t seem natural enough.

It’s like picking 2020 as the beginning of an epoch now (of course we’d probably fall back to 2000 as that’s a big round number).

Re:New UUID Formats – IETF Draft by fsagx on Friday August 06, 2021 @09:19PM (#28094792)
Other fun non-Jan 1 ideas

1997-08-29T06:14:00Z

Re:New UUID Formats – IETF Draft by zvrba on Saturday August 07, 2021 @01:38AM (#28096023)
> Here's a thought experiment [...] I would pick the Unix epoch, because I think others would do the same.

Ah yes, nobody will ever need to represent a date/time before 1970-01-01.

As for your thought experiment: recently I had to pick a "NULL/no/unknown date" value to put into a non-nullable database column and I picked 1900-01-01. Unix epoch crossed my mind only briefly and I discarded it immediately because it's too arbitrary and, more importantly, too near valid dates that the user might use. (Use-case: materials from historical archives being ingested.)

So my opinion is that the RFC authors should be commended for having the foresight of choosing an epoch that's widely more applicable and far less arbitrary (the 1st day of the calendar system that most of the world is using today) than the Unix epoch.

Re:New UUID Formats – IETF Draft by michaelt on Saturday August 07, 2021 @09:25AM (#28098420)
> Ah yes, nobody will ever need to represent a date/time before 1970-01-01.

If only we had a way to represent numbers less than zero :)

Re:New UUID Formats – IETF Draft by account42 on Monday August 09, 2021 @03:55AM (#28113719)
Will UUIDs with your favourite encoding for negative numbers put 1969-01-01 before or after 1970-01-01 with a lexicographical sort of the UUID bytes?
Re:New UUID Formats – IETF Draft by TheCoelacanth on Saturday August 07, 2021 @12:44PM (#28099934)
I think it's certainly rather unlikely that anyone will ever need to generate a v6-8 UUID before 1970.
Re:New UUID Formats – IETF Draft by scottlamb on Saturday August 07, 2021 @10:47AM (#28098965)
> Ah yes, nobody will ever need to represent a date/time before 1970-01-01.

More like: the few people interested in doing this can use UUIDv8 (unspecified time format). There are many, many reasons to store times before 1970 in computer systems, but I'm not sure any apply to these UUID formats.

tl;dr of the "Background" section of the RFC: they're designing it so that two UUIDs with fresh timestamps will have values near each other in the database keyspace, which in many cases improves efficiency. If your timestamp isn't freshly generated, I don't know why you'd embed it in a UUID with these formats.

It's arguably not a good practice to extract the timestamp from the UUID at all. Instead, I might just treat them once generated as opaque approximately-sorted bytes. More clear to have a separate fields for timestamps with particular importance. Though I might not feel too religious about that if tight on storage space.

Re:New UUID Formats – IETF Draft by zvrba on Saturday August 07, 2021 @11:42AM (#28099429)
> If your timestamp isn't freshly generated, I don't know why you'd embed it in a UUID with these formats.

Ingesting past/archival data. As to why use these formats: to still benefit from their sorting properties. As to why use UUID at all: because it's a format understood by a wide variety of software.

> It's arguably not a good practice to extract the timestamp from the UUID at all.

Ya, I'd do it only if I trust the source (i.e., a closed system).

Re:New UUID Formats – IETF Draft by scottlamb on Saturday August 07, 2021 @06:05PM (#28102309)
> Ingesting past/archival data. As to why use these formats: to still benefit from their sorting properties. As to why use UUID at all: because it's a format understood by a wide variety of software.

Their argument about the value of sorting is quite particular. Put stuff roughly in ascending order by the record creation time so that creating a bunch of records will touch (eg) fewer btree nodes. The simplest way to achieve that is to just use the current time. If you have some other timestamp at hand and happen to be scanning them in ascending order by that, you still get no advantage by this argument over just using the current timestamp:

> However some properties of [RFC4122] UUIDs are not well suited to this task. First, most of the existing UUID versions such as UUIDv4 have poor database index locality. Meaning new values created in succession are not close to each other in the index and thus require inserts to be performed at random locations. The negative performance effects of which on common structures used for this (B-tree and its variants) can be dramatic. As such newly inserted values SHOULD be time-ordered to address this.

My gut tells me that you should rarely if ever stick past timestamps in UUID primary keys. One reason why: can it ever change? Maybe your artifact dating technique was wrong, and you want to update the dates of a bunch of artifacts. But now you have to change your primary key. You probably don't want that.

Re:New UUID Formats – IETF Draft by zamadatix on Friday August 06, 2021 @05:26PM (#28092935)
Yet that thought process wouldn't allow for the Unix epoch in the first place.
Re:New UUID Formats – IETF Draft by MrManatee on Friday August 06, 2021 @05:45PM (#28093115)
I wouldn't say it makes "little sense". Just like we can talk about the year 776 BC even though no one at the time called it that, we can extend the Gregorian calendar backwards to dates when it wasn't used anywhere. The Wikipedia article on the proleptic Gregorian calendar lists some use cases. [1]

And in any case, 15 October 1582 isn't some hard cutoff point where we can stop worrying about calendar conversions. Only four countries adopted the Gregorian calendar on that day, and even in Europe there are several countries that only switched in the 20th century. If a piece of software needs to support historical dates that go anywhere near 1582, it needs to be aware of the existence of different calendars.

[1] https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar

Re:New UUID Formats – IETF Draft by jefftk on Friday August 06, 2021 @02:13PM (#28090955)
> Talking about dates before this epoch makes little sense (any date before the Gregorian epoch will not resemble the same stellar / planet constellation as date after the Gregorian epoch).

That is not the only sense in which we care about dates. For example, we might want to talk about which of two events came first, and by how much. Historians have lots of uses for dates before the introduction of the Gregorian calendar.

Re:New UUID Formats – IETF Draft by SBArbeit on Friday August 06, 2021 @04:02PM (#28092112)
Yes, but we won't need 100ns precision for those historical dates.
Re:New UUID Formats – IETF Draft by zvrba on Saturday August 07, 2021 @01:59AM (#28096117)
Historically, calendars came to be from observing the movement of planets and stars. Now:

> we might want to talk about which of two events came first, and by how much

Neither of which makes sense without having a common reference point (start of Gregorian calendar being one such possible reference point). Trivial example: there is exactly one day between 1582-10-04 (Julian c.) and 1582-10-15 (Gregorian c.), i.e., different reference points.

> Historians have lots of uses for dates before the introduction of the Gregorian calendar.

Yes, and I bet they're hyper-aware about the calendar system(s) they're using. The rest of our mortals can just use Gregorian calendar :)

Re:New UUID Formats – IETF Draft by contravariant on Friday August 06, 2021 @05:22PM (#28092895)
Surely they'd be using some kind of timestamp standard not a UUID?
Re:New UUID Formats – IETF Draft by ygra on Friday August 06, 2021 @03:35PM (#28091807)
Windows' FILETIME uses a different epoch, though. It counts since 1601 (the then-most-recent 400-year leap-year cycle when Windows NT was designed).
Re:New UUID Formats – IETF Draft by hn_throwaway_99 on Friday August 06, 2021 @01:48PM (#28090582)
To clarify, are those "plus some random bits" parts intended to be randomly generated for each individual UUID that is created, or randomly generated once per machine or startup?

I ask because a common newbie bug is to use a UUID as a secure token, but currently only v4 UUIDs with a cryptographically secure PRNG can be used this way. Separately, even if not used as a token, using UUIDs with randomness for object IDs can help mitigate IDOR vulnerabilities if there are other bugs in code that aren't adequately checking object permissions.

Re:New UUID Formats – IETF Draft by pjscott on Friday August 06, 2021 @01:53PM (#28090651)
They're to be generated for each individual UUID. (However, this RFC recommends using the entirely random UUID4 for anything that's meant to be used in a security-related context, presumably with a CSPRNG.)
Re:New UUID Formats – IETF Draft by hn_throwaway_99 on Friday August 06, 2021 @02:42PM (#28091263)
Thanks. To be honest then, that last bit, "this RFC recommends using the entirely random UUID4 for anything that's meant to be used in a security-related context, presumably with a CSPRNG." makes me think this RFC could cause some problems.

v6 UUIDs only have 48 bits of randomness, which means that some newbies will think that's "good enough" for security, when in reality it's not.

I still like these new UUID types because I would use them as DB primary keys now (benefit of being time sorted but also globally unique and offers some protection against IDOR bugs), but important to know where not to use them.

Re:New UUID Formats – IETF Draft by pjscott on Friday August 06, 2021 @02:57PM (#28091439)
Yeah, I'm a bit torn on this security-wise. On the one hand, their only real security-relevant ambition here is to avoid leaking MAC address info, a classic UUID foot-gun, and they do achieve this. Probably a much better set of defaults! On the other hand, yeah, the mere presence of some random bits could lull people into a false sense of safety, especially as the RFC doesn't say anything about where those bits should come from except that it should have enough entropy to make collisions minimal. On the third hand, anybody who thinks that 48 random bits of unspecified provenance are enough for a secure token was probably always going to mess up somehow, so I'm not sure how much difference this makes on the margin.
Re:New UUID Formats – IETF Draft by staticassertion on Friday August 06, 2021 @06:13PM (#28093363)
I feel like understanding the guarantees is really simple. A value can be unique while still being guessable, and that's the idea with this latest revision. If you want something to be unique and unguessable, that's another uuid (or just use random bits, there's no benefit to a uuid here, generally).
Re:New UUID Formats – IETF Draft by zaphirplane on Friday August 06, 2021 @11:36PM (#28095463)
UUID are better than random for distributed ID generation, I though
Re:New UUID Formats – IETF Draft by staticassertion on Saturday August 07, 2021 @07:05AM (#28097631)
Nope, v4 are just random with a version tag.
Re:New UUID Formats – IETF Draft by aidos on Friday August 06, 2021 @04:50PM (#28092586)
They’re perfect for client generation of db ids. I was looking to do exactly this format, but decided not to do anything that was weirdly non-standard.

Uuid6 is the one I’ll be switching to now.

Re:New UUID Formats – IETF Draft by rndgermandude on Saturday August 07, 2021 @12:23AM (#28095670)
UUIDv4 (or even worse, the other versions) are regularly used for "security", as you said, when they shouldn't. That won't change with these proposed versions.

Any randomness in the UUIDs is meant to minimize the possibility of collisions. If e.g. you only used a timestamp then you might get collisions even on the same machine, and are almost guaranteed collisions sooner than later on a global scale.

The draft mentions randomness in the background section, but not really.

> Lastly, privacy and network security issues arise from using a MAC address in the node field of Version 1 UUIDs. Exposed MAC addresses can be used as an attack surface to locate machines and reveal various other information about such machines (minimally manufacturer, potentially other details). Instead "cryptographically secure" pseudo-random number generators (CSPRNGs) or pseudo-random number generators (PRNG) SHOULD be used within an application context to provide uniqueness and unguessability.

And in the Security Considerations section

> Instead [of MACs] pseudo-random bits SHOULD selected from a source with sufficient entropy to ensure guaranteed uniqueness among UUID generation.

However, the rest of the document does not mention how to generate the random data, at all. If the draft advanced to RFC or even standard like this, it would be fine to use the "Debian PRNG")[1].

Then again, only the proposed v6 mandates any random data at all (and 48-bits "only"). v7 and v8 have essentially a "may use" for any randomness.

Using only UUIDs for "security" is generally a bad idea in my humble opinion, regardless, even if v4 with a crypto-secure (CS)PRNG. But I suppose, mandating the use crypto-secure (CS)PRNG would still alleviate some of the injuries to people who point the UUID-gun at their feet and pull the trigger.

[1] https://i.imgur.com/WkLh32P.png [2]

[2] https://www.debian.org/security/2008/dsa-1571

Re:New UUID Formats – IETF Draft by staticassertion on Saturday August 07, 2021 @09:32AM (#28098458)
> UUIDv4 (or even worse, the other versions) are regularly used for "security", as you said, when they shouldn't. That won't change with these proposed versions.

UUIDv4 can be entirely suitable for security purposes, so long as the implementation is defined to use a secure RNG, which most sane implementations would be (since that's the dead simplest way to ensure the guarantees of UUIDv4).

Most people use them for security purposes because libraries for UUID tend to make it easy - you get 122bits of randomness (more than enough for many use cases), a nice way to convert to strings in multiple formats, parsers, etc.

Re:New UUID Formats – IETF Draft by pixl97 on Saturday August 07, 2021 @08:42AM (#28098183)
Heh, v4 had to be from before VMs were common and MACs easily duplicated.
Re:New UUID Formats – IETF Draft by staticassertion on Saturday August 07, 2021 @09:33AM (#28098466)
v4 doesn't use a MAC address, you're thinking of V1 and V2.
Re:New UUID Formats – IETF Draft by dspillett on Friday August 06, 2021 @02:41PM (#28091257)
> only v4 UUIDs with a cryptographically secure PRNG can be used this way

Only they should be used that way. Unfortunately other options (other UUID types, v4 with bad RNG) are sometimes used that way. At least other UUID variants are more faf to hack around than a simple increasing integer, particularly if decent request and access validation is in place, though if the wrong type of key is being used perhaps hoping for good validation elsewhere is a bit much.

Re:New UUID Formats – IETF Draft by paulddraper on Friday August 06, 2021 @03:21PM (#28091680)
8 kinds of UUIDs, because we already had 4 too many.
Re:New UUID Formats – IETF Draft by pjscott on Friday August 06, 2021 @03:28PM (#28091733)
Which of the 5 existing kinds of UUID do you consider the One True UUID? No matter which you pick, I guarantee that there's something badly wrong with it for at least one common use-case that can be improved by switching to either v4 (IMHO the only one of the existing types worth using) or to one of the new proposed UUID types.
Re:New UUID Formats – IETF Draft by paulddraper on Friday August 06, 2021 @03:33PM (#28091787)
UUID v4

Are you concerned about the 0.0000001% chance of collision after generating a 100 trillion UUIDs?

Or are you trying to include metadata in your identifier? (Not the worst thing, but it's also not super useful info.)

Re:New UUID Formats – IETF Draft by pjscott on Friday August 06, 2021 @03:39PM (#28091853)
I'm not worried about collisions and I agree that being able to put metadata in the UUID is a big meh of a feature. The problem with v4 is what happens when people try using them as database keys: the random sort order can really hurt performance. You might argue that the fix for this is to simply not use UUIDs as database keys... but so many people are already doing this, and will continue to do it, that they should probably be given better standard options.
Re:New UUID Formats – IETF Draft by paulddraper on Friday August 06, 2021 @04:52PM (#28092602)
> random sort order can really hurt performance

I've long thought it was a problem that PostgreSQL doesn't have a real clustering key like MySQL or SQL Server.

But PostgreSQL users have told me it doesn't really matter.

Re:New UUID Formats – IETF Draft by dtech on Friday August 06, 2021 @06:10PM (#28093344)
It's much less important in postgres as in some other databases, but it still hurts.

Mainly because indices have to be updated and searched all over the place with UUIDs. The locality of the data on disk itself is fine because its inserted sequential.

Re:New UUID Formats – IETF Draft by anarazel on Friday August 06, 2021 @06:17PM (#28093403)
> But PostgreSQL users have told me it doesn't really matter.

Those users were very wrong, unless they explicitly only talked about the case where the uuids are not indexed.

Re:New UUID Formats – IETF Draft by mjevans on Friday August 06, 2021 @07:47PM (#28094140)
They'd likely argue to use natural keys instead. Use the data that matters to you, index it across more than one column.
Re:New UUID Formats – IETF Draft by anarazel on Friday August 06, 2021 @08:45PM (#28094537)
For cases where one sensibly used uuids, I don't see natural keys being an alternative. What's e.g. the natural key of an order reference that should be accessible without auth, when the key shouldn't allow enumeration and that should be allocatable without a single point of coordination?
Re:New UUID Formats – IETF Draft by mdtusz on Friday August 06, 2021 @04:17PM (#28092265)
This is a fairly significant issue for mysql, but does the same issue exist when using postgres with a UUID pk type?

At my last job, this was managed by using two ID's on each row - a serial one that was basically only used for database optimization purposes, and the "real" UUIDv4 ID. It felt gross then, and it feels gross now, but it seemed to do the trick for our needs.

Re:New UUID Formats – IETF Draft by johncolanduoni on Friday August 06, 2021 @05:03PM (#28092716)
It doesn’t, since Postgres doesn’t actively use the primary key for clustering.
Re:New UUID Formats – IETF Draft by anarazel on Friday August 06, 2021 @08:56PM (#28094636)
It still increases write rate a lot over more sequential values / reduced cache hit ratio.

With sequential-ish values indexed by something like b-trees the same index pages get modified over and over again because new table rows will be in a narrow part of the index. As databases / operating systems typically buffer writes for a while, this reduced the number of writes hitting storage substantially.

Conversely, with random values, every leaf page will be modified with the same probability. That's not problem with a small index, because you'll soon dirty every page anyway. But as soon as the index gets larger you'll see many more writes hitting storage.

Re:New UUID Formats – IETF Draft by lazide on Saturday August 14, 2021 @11:13AM (#28181270)
FYI - for anyone running across this thread later. This is a unique problem with (a kind of globally) consistent storage on small (single node equivalent) systems. If you have a large scale distributed system, you WANT writes to be well distributed across all nodes, or you’ll end up with problematic hot spots.

All new writes ending up on the same node/page/index is a good way to crush your system in a cascading-never-coming-back-up-until-you-drain-traffic-kind-of-way

Re:New UUID Formats – IETF Draft by TheCoelacanth on Saturday August 07, 2021 @12:58PM (#28100047)
The other versions all have use cases other than avoiding collisions.

If your access patterns are such that you often access ids generated around the same time together v6-8 will probably be faster due to locality. If you access data generated on the same node together, than same for v1-2.

If you want a reproducible id based on some other identifier, then only v3 and v5 will work.

Re:New UUID Formats – IETF Draft by hinkley on Friday August 06, 2021 @06:34PM (#28093551)
> UUID6: a timestamp with a weird epoch and 100 ns precision like in UUID1, but in a big-endian order that sorts naturally by time

So even the IETF hasn’t read Things Every Developer Should Know About Time.