Picking something that generates unique values is very importiant. If your application ends up being distributed across multiple web servers, will your session id generator still generate provably unique ids?

One security aspect revolves around issues of session hijacking. If an attacker can repeatedly request new session ids untill they figure out how the generator works, they may be able to predict valid session ids, and use them to access (hijack) sessions of your active users. For an ecommerce site, this can be a serious issue. Generating a duplicate id can lead to 2 users sharing the same session - possibly exposing sensitive information from one user to the other.

There is a discussion about some of this in the book Writing Apache Modules with Perl and C.

Some techniues that I've seen used are to embed the user's ip address in the session id, and to append an md5 sum computed from the session id plus some information on the server (that is only available on the server). The appended md5 sum can then be used to validate that the id was generated by your website, and the ip address can be validated against the remote user's ip. That simple validation goes a long way toward thwarting session hijacking.


In reply to Re: Secure Session ID values by mortis
in thread Secure Session ID values by Hero Zzyzzx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.