Encode and Decode, DES/DESEDE algorithm conumdrum
Because of a customer requirement, we cannot use Session variable to pass things like item ID values. As a result, I’ve been using encrypted URL’s to do this kind of thing. We discovered by chance the other day, that you could change the HEX encoded (using CFMX_COMPAT algorithm) URL values and change the item ID, which would let the user move to a place he isn’t supposed to go. OOOOps.
I have been using the Session.SessionID as a basis for the key of the CFMX_COMPAT encryption for about 18 months now and no one has discovered this hole in the system, but I guess it is only a matter of time before someone does. Today I tried to figure out how to use the DESEDE algorithm but the thing that has me stymied is how you pass are supposed to pass the key value across to the Decrypt code. In all the manuals and all the examples they show only, they cheat; i.e., the work both sides of Encrypt/Decrypt process from the same form. Well, you can’t do that when you are going across the URL bridge. I suppose I could encrypt the DESEDE key that I generate using the generateSecretKey(“DESEDE”) using CFMX_COMPAT and then decode it across the other side of the URL bridge using the Session.SessionID, but this seems to be getting out of hand.
One other issue, I have to pass things via email between systems so I do have to pass the Session.SessionID value between different Cold Fusion systems, but I have come up with a way treat a passed in Session.SessionID value as a one-time, throw-away key.
Note: I can only get by using the Session.SessionID value because it remains the same throughout the user’s whole session and is not related to any particular item as it would be if I were still using Session.ItemID’s.
As a stop-gap measure I am doubly encrypting the ItemID before I assign it to the URL. After the 1st encryption I append a known string to the 1st encrypted value and then do my 2nd encryption: url_DblStr=”#EnCrypt(#1stEnCryptStr#wxyz)#”. After I’ve done my 1st decryption on the other side, I ensure that the “wxyz” string is still intact on the end of the 1stEnCryptStr. If it has been changed, then I know that someone changed something in the URL and I can send them to a place where they can do no harm.
So here is my simple question: How can you use DES/DESEDE/etc. algorithms, which seems to require you to use the generateSecureKey() function, when you can not directly share the key through Form or Session variables?
There must be a simple way to do this thing that has not occurred to me even though I have given it a considerable amount of though over the last 24 hours.
Thank you in advance for your help and suggestions.
:-}
Len
