views:

988

answers:

5

GUIDs get used a lot in creating session keys for web applications. I've always wondered about the safety of this practice. Since the GUID is generated based on information from the machine, and the time, along with a few other factors, how hard is it to guess of likely GUIDs that will come up in the future. Let's say you started 1000, or 10000 new sessions, to get a good dataset of the GUIDs being generated. Would this make it any easier to generate a GUID that might be used for another session. You wouldn't even have to guess a specific GUID, but just keep on trying GUIDs that might be generated at a specific period of time.

+8  A: 

Here is some stuff from Wikipedia:

V1 GUIDs which contain a MAC address and time can be identified by the digit "1" in the first position of the third group of digits, for example {2f1e4fc0-81fd-11da-9156-00036a0f876a}.

In my understanding, they don't really hide it.

V4 GUIDs use the later algorithm, which is a pseudo-random number. These have a "4" in the same position, for example {38a52be4-9352-453e-af97-5c3b448652f0}. More specifically, the 'data3' bit pattern would be 0001xxxxxxxxxxxx in the first case, and 0100xxxxxxxxxxxx in the second. Cryptanalysis of the WinAPI GUID generator shows that, since the sequence of V4 GUIDs is pseudo-random, given the initial state one can predict up to next 250 000 GUIDs returned by the function UuidCreate[1]. This is why GUIDs should not be used in cryptography, e. g., as random keys.

Uri
Good information. However, how does one obtain the "initial state"?
Kibbee
What would really be interesting is having a function f(n) that given a guid n returns the guid y that winapi will generate next. I am fairly certain the time is used as part of the random seed (this could be validated with a VM) I dont trust this info on wikipedia to be correct
Sam Saffron
A: 

Depends. It is hard if the GUIDs are set up sensibly, e.g. using salted secure hashes and you have plenty of bits. It is weak if the GUIDs are short and obvious.

You may well want to be taking steps to stop someone create 10000 new sessions anyway due to the server load this might create.

Dickon Reed
A: 

If someone kept hitting a server with a continuous stream of GUIDs it would be more of a denial of service attack than anything else.

The possibility of someone guessing a GUID is next to nil.

hmcclungiii
+1  A: 

.NET Web Applications call Guid.NewGuid() to create a GUID which is in turn ends up calling the CoCreateGuid() COM function a couple of frames deeper in the stack.

From the MSDN Library:

The CoCreateGuid function calls the RPC function UuidCreate, which creates a GUID, a globally unique 128-bit integer. Use the CoCreateGuid function when you need an absolutely unique number that you will use as a persistent identifier in a distributed environment.To a very high degree of certainty, this function returns a unique value – no other invocation, on the same or any other system (networked or not), should return the same value.

And if you check the page on UuidCreate:

The UuidCreate function generates a UUID that cannot be traced to the ethernet/token ring address of the computer on which it was generated. It also cannot be associated with other UUIDs created on the same computer.

The last contains sentence is the answer to your question. So I would say, it is pretty hard to guess unless there is a bug in Microsoft's implementation.

DrJokepu
There are plenty of web applications that don't run on Microsoft platforms.
John Topley
That only states that it's unlikely that calling the CoCreateGuid function would return the same value twice. It says nothing about constructing your own algorithm that generates probable GUIDs based on previous ones.
Kibbee
Kibbee: I have extended it with a bit more explanation.
DrJokepu
John Topley: Obviously, one cannot say that the GUID generation algorithm is secure on all platforms. For example, I could write a PHP class that generates GUIDs by adding one to the previous one. Still, it makes sense to talk about the Microsoft implementation because it is used by a lot of people.
DrJokepu
+3  A: 

GUIDs are guaranteed to be unique and that's about it. Not guaranteed to be be random or difficult to guess.

TO answer you question, at least for the V1 GUID generation algorithm if you know the algorithm, MAC address and the time of the creation you could probably generate a set of GUIDs one of which would be one that was actually generated. And the MAC address if it's a V1 GUID can be determined from sample GUIDs from the same machine.

Additional tidbit from wikipedia:

The OSF-specified algorithm for generating new GUIDs has been widely criticized. In these (V1) GUIDs, the user's network card MAC address is used as a base for the last group of GUID digits, which means, for example, that a document can be tracked back to the computer that created it. This privacy hole was used when locating the creator of the Melissa worm. Most of the other digits are based on the time while generating the GUID.

Davy8