in reply to Re: Re: cookies n variables
in thread cookies n variables

  1. If you encrypt using md5, how do you expect do decrypt?
  2. If you encrypt using another scheme, how do you get back data the user has deleted from the cookie?

There is only one truely safe way to do this, and that is to maintain state with a cookie (or hidden params) (see previous post). The information stored server side is non-volatile, any information stored in a cookie is volatile and susceptible to tampering/attack/deletion et al.

Using a session NDV session id makes everything *that* much more safer. Of course there is safe and there is *safe*, and any solution chosen should represent the level of risk allowable for the project.

For example a site may manage content via a cookie, and default to a default page if the cookie is not found, however a bank may use any combination of challenge/response using a 3rd party token generator (ala secure_id)...

IMO it is *so* easy to produce a decent level of security with a NDV sess_id, and storing the information server side, why not do it? why put information into a volitile data source?

Replies are listed 'Best First'.
Re: Re: Re: Re: cookies n variables
by waswas-fng (Curate) on Nov 17, 2002 at 19:08 UTC
    You can do a pair of cookies, one with the data. the second md5 hashed with the data and a private string that only your cgi knows. That way when the data cookie is retrived you can take the data cookie returned + the private string, then hash and compair to the md5 cookie you sent. It will tell you if the data has been changed.

    -Waswas
      Yup, that would work, except now, if you need to change the key because of whatever reason (employee leaves, server is compromised et al), there is a bit of a mess to work out.
        Pretty simple as they are just session data holders, just change the secret string that mods the hash if an employee leaves. The cgi should be written well enough to deal with bad/missing data cookies and give the user another chance to provide it. As far as the server being compromised -- lol you have more to worry about then the cookie hash =) the hacker cacn do far more damage with other means available to them at that point.

        -Waswas