Session theft?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dani CS

    #16
    Re: Session theft?

    Johnny Elvers wrote:[color=blue]
    > Dani CS wrote:
    >[color=green]
    > > The trick is not to use one _fixed_ session id during the wholesession,
    > > but rather a _different_ session id for every client->server interaction
    > > (i.e. every time a new page is fetched from the server). In other words,
    > > multiple single-use session-ids for each session.
    > >
    > > A (single use) session id can be calculated from previos session ids and
    > > a secret shared between client and server (e.g. the password used for
    > > authentication of the user). This means that client and server must be
    > > in sync. Along with each request, the client must send the next session
    > > id that the server expects. This is why the 'back' button must not be
    > > used: the session id of the previous page would be sent to the server,
    > > but the server expects to get the session id for a new page. (I haven't
    > > worked at fixing this at the moment.)
    > >
    > > The generated session ids must be difficult to guess just by looking at
    > > previous session ids, so a one-way hash can be very useful (my
    > > implementation uses MD5).
    > >[/color]
    >
    > Why the clientside calculations really ? Why not just have the server
    > generate a new UID that the client must use for the next page view ?[/color]

    A session thief could retrieve the UID when it travels down to the
    cliend, and use it right before the legitimate client uses it.
    [color=blue]
    >
    > And if you store the generated session history you'll have some extra
    > options.
    >
    > - Let's say a UID was stolen or sniffed. When the user tries to access
    > the next page he will be asked to login, sending along the invalid UID.
    > If login succeed it will take precedence over the latest used UID's and
    > you'll have a track from the real users, former, invalid UID up to the
    > latest.[/color]

    I don't keep a history because I didn't see the need when I developed
    this experiment, but the idea sounds good to me. Apart from that,
    anytime that a user sends a wrong UID, they are presented the login
    window again, just like you say.
    [color=blue]
    >
    > - If you want to relax security a bit, you could allow the last or the
    > last n sessions to be valid within a time span, allowing for Back button
    > functionality.[/color]

    This could work, but I'll keep searching for a while on ways to make the
    'back' button usable. Maybe the onunload() javascript event can help.
    [color=blue]
    >
    > /Johnny[/color]

    Comment

    • Robert Tweed

      #17
      Re: Session theft?

      "Dani CS" <contusiones.me rluza@yahoo.es. quita-la-merluza> wrote in message
      news:cpuaqq$khj $1@news.ya.com. ..[color=blue]
      >
      > The main concern (appart from breaking the 'back' button) is hiding the
      > password on the client to prevent cross-site scripting attacks that
      > could retrieve it. This is caused by the need to keep the shared secret
      > in the client's memory to generate each one of the new session ids.[/color]

      I _think_ (not 100% certain about this) that you can avoid XSS attacks as
      follows:

      - When user goes to admin URL, open a new window to begin the session in.
      - Ensure that the name of the new window is _blank; or, if using
      window.open, create a totally random name based on the time - the more
      entropy the better.
      - Try to ensure that users only enter the admin system via this "window with
      no name".

      This should prevent any script from accessing values on your admin system
      pages, as they are entirely contained in a window with no known target name.
      It would not stop a specially written trojan, but then if you've got trojans
      on your system then you've got more to worry about than session theft.

      - Robert


      Comment

      • Johnny Elvers

        #18
        Re: Session theft?

        [color=blue][color=green]
        >> Why the clientside calculations really ? Why not just have the server
        >> generate a new UID that the client must use for the next page view ?[/color]
        >
        >
        > A session thief could retrieve the UID when it travels down to the
        > cliend, and use it right before the legitimate client uses it.
        >[/color]

        Right, but the same applies to the client side algorithms.
        For measurements against generic theft your point is taken though.
        [color=blue]
        > This could work, but I'll keep searching for a while on ways to make the
        > 'back' button usable. Maybe the onunload() javascript event can help.[/color]

        Could be. Take a look at the XMLHttpRequest object.

        /Johnny

        Comment

        • Dani CS

          #19
          Re: Session theft?

          Johnny Elvers wrote:[color=blue]
          >[color=green][color=darkred]
          >>> Why the clientside calculations really ? Why not just have the server
          >>> generate a new UID that the client must use for the next page view ?[/color]
          >>
          >>
          >>
          >> A session thief could retrieve the UID when it travels down to the
          >> cliend, and use it right before the legitimate client uses it.
          >>[/color]
          >
          > Right, but the same applies to the client side algorithms.
          > For measurements against generic theft your point is taken though.[/color]

          I was assuming that the thief can see the data, but not touch it. In
          this case, even if the thief gets the new_sid that travels from the
          client to the server, it will be worthless, because that new_sid has
          already arrived to the server and is no longer valid.

          If there is someone in the middle who can manipulate the data, only SSL
          or similar would be good.

          Comment

          • Johnny Elvers

            #20
            Re: Session theft?

            [color=blue][color=green][color=darkred]
            >>>
            >>> A session thief could retrieve the UID when it travels down to the
            >>> cliend, and use it right before the legitimate client uses it.
            >>>[/color]
            >>
            >> Right, but the same applies to the client side algorithms.
            >> For measurements against generic theft your point is taken though.[/color]
            >
            >
            > I was assuming that the thief can see the data, but not touch it. In
            > this case, even if the thief gets the new_sid that travels from the
            > client to the server, it will be worthless, because that new_sid has
            > already arrived to the server and is no longer valid.
            >[/color]

            But the thief can do the same calculations as the client.

            But you are right of cause, as this is about session theft and not
            hacking attempts :)

            /Johnny

            Comment

            • Dani CS

              #21
              Re: Session theft?

              Johnny Elvers wrote:[color=blue]
              >[color=green][color=darkred]
              >>>>
              >>>> A session thief could retrieve the UID when it travels down to the
              >>>> cliend, and use it right before the legitimate client uses it.
              >>>>
              >>>
              >>> Right, but the same applies to the client side algorithms.
              >>> For measurements against generic theft your point is taken though.[/color]
              >>
              >>
              >>
              >> I was assuming that the thief can see the data, but not touch it. In
              >> this case, even if the thief gets the new_sid that travels from the
              >> client to the server, it will be worthless, because that new_sid has
              >> already arrived to the server and is no longer valid.
              >>[/color]
              >
              > But the thief can do the same calculations as the client.[/color]

              He needs the password to get the nex_sid from the current_sid. Only the
              legitimate client knows that password.
              [color=blue]
              >
              > But you are right of cause, as this is about session theft and not
              > hacking attempts :)
              >
              > /Johnny[/color]

              Comment

              • Johnny Elvers

                #22
                Re: Session theft?

                Dani CS wrote:[color=blue]
                >
                > He needs the password to get the nex_sid from the current_sid. Only the
                > legitimate client knows that password.
                >[/color]

                Yes, but the point is that whatever resides inside the client, in a non
                ssl (or the like) encrypted setup, is public. So password, algorithm and
                whatever is transmitted is copyable.
                So whatever is sent, the actual password or an md5'ed password or
                whatever doesn't really matter. All the thief has to do is intercept and
                replicate the client functionality.

                /Johnny

                Comment

                • Dani CS

                  #23
                  Re: Session theft?

                  Johnny Elvers wrote:[color=blue]
                  > Dani CS wrote:
                  >[color=green]
                  >>
                  >> He needs the password to get the nex_sid from the current_sid. Only
                  >> the legitimate client knows that password.
                  >>[/color]
                  >
                  > Yes, but the point is that whatever resides inside the client, in a non
                  > ssl (or the like) encrypted setup, is public. So password, algorithm and
                  > whatever is transmitted is copyable.
                  > So whatever is sent, the actual password or an md5'ed password or
                  > whatever doesn't really matter. All the thief has to do is intercept and
                  > replicate the client functionality.[/color]

                  The password is never sent over the net. It is typed down by the user on
                  the client, and then stored in a javascript variable. The thief can't
                  see it.
                  [color=blue]
                  >
                  > /Johnny[/color]

                  Comment

                  • Chris Hope

                    #24
                    Re: Session theft?

                    Dani CS wrote:
                    [color=blue]
                    > Johnny Elvers wrote:[color=green]
                    >> Dani CS wrote:
                    >>[color=darkred]
                    >>>
                    >>> He needs the password to get the nex_sid from the current_sid. Only
                    >>> the legitimate client knows that password.
                    >>>[/color]
                    >>
                    >> Yes, but the point is that whatever resides inside the client, in a
                    >> non ssl (or the like) encrypted setup, is public. So password,
                    >> algorithm and whatever is transmitted is copyable.
                    >> So whatever is sent, the actual password or an md5'ed password or
                    >> whatever doesn't really matter. All the thief has to do is intercept
                    >> and replicate the client functionality.[/color]
                    >
                    > The password is never sent over the net. It is typed down by the user
                    > on the client, and then stored in a javascript variable. The thief
                    > can't see it.[/color]

                    But what if they can work out what the javascript variable is called?
                    Then it's just a matter of typing javascript:wind ow.alert(foo) into the
                    address bar in Internet Explorer or Mozilla to get the value,
                    subsituting "foo" for the variable name in my example.

                    --
                    Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

                    Comment

                    • Johnny Elvers

                      #25
                      Re: Session theft?

                      [color=blue]
                      >
                      > The password is never sent over the net. It is typed down by the user on
                      > the client, and then stored in a javascript variable. The thief can't
                      > see it.[/color]

                      Yes he can. It is not simply a matter of traffic.
                      Sniffing is sometimes complicated. Parsing client content is, for most
                      parts, not.

                      /Johnny

                      Comment

                      • Chung Leong

                        #26
                        Re: Session theft?

                        "Robert Tweed" <robertNOSPAM@k illingmoon.com> wrote in message
                        news:32f88iF3kg u43U1@individua l.net...[color=blue]
                        > Does anyone know a good resource discussing the issues involved in session
                        > theft? I've read a couple, but none that really address the problem apart
                        > from acknowledging that it is a problem; you just don't seem to be able to
                        > do much about it.
                        >
                        > Does anyone have some tried-and-tested measures for preventing session
                        > theft, that aren't already built into PHP? For that matter, what measures
                        > _are_ already built into PHP? Are there significant differences between[/color]
                        PHP4[color=blue]
                        > and PHP5?[/color]

                        Easy. Don't rely on session for authentication (that is, in pages
                        subsequent to the login page). Authenticate with the HTTP digest method
                        instead. Session hijacking is basically a form of playback attack. A
                        properly implemented digest authentication is resistant to that.


                        Comment

                        • Dani CS

                          #27
                          Re: Session theft?

                          Johnny Elvers wrote:[color=blue]
                          >[color=green]
                          >>
                          >> The password is never sent over the net. It is typed down by the user
                          >> on the client, and then stored in a javascript variable. The thief
                          >> can't see it.[/color]
                          >
                          >
                          > Yes he can. It is not simply a matter of traffic.
                          > Sniffing is sometimes complicated. Parsing client content is, for most
                          > parts, not.[/color]

                          If the only thing the thief can do is look at the data on the wire, but
                          never change it, how could him grab something that is _never_ sent over
                          the wire?

                          If he can change the data on the wire, this and any other method of
                          authentication/session-management (lacking proper encryption) is already
                          defeated.

                          Apart from that, someone has already suggested a way to avoid cross-site
                          scripting vulnerabilities , by assigning a random ("impossible " to guess)
                          name to the window where all the data are.
                          [color=blue]
                          >
                          > /Johnny[/color]

                          Comment

                          • Robert Tweed

                            #28
                            Re: Session theft?

                            "Chung Leong" <chernyshevsky@ hotmail.com> wrote in message
                            news:sIWdnekOd5 sq8l7cRVn-ug@comcast.com. ..[color=blue]
                            >
                            > Easy. Don't rely on session for authentication (that is, in pages
                            > subsequent to the login page). Authenticate with the HTTP digest method
                            > instead. Session hijacking is basically a form of playback attack. A
                            > properly implemented digest authentication is resistant to that.[/color]

                            From what I've read about digest authentication it is no more secure than
                            plain HTTP authentication, except that an attacker won't actually get your
                            password in cleartext. They can still bypass your security using the hash.

                            OK, so you get rid of the problem of session theft, but you are just
                            shifting the issue: getting rid of one problem at the cost of another
                            problem.

                            Also, there appear to be some compatability problems with browsers and it is
                            not fully supported by Apache (although this last part may be out of date).

                            Am I correct about this, or have I got the facts wrong?

                            - Robert


                            Comment

                            • nospam@geniegate.com

                              #29
                              Re: Session theft?

                              Dani CS <contusiones.me rluza@yahoo.es. quita-la-merluza> wrote:[color=blue]
                              > The trick is not to use one _fixed_ session id during the wholesession,
                              > but rather a _different_ session id for every client->server interaction
                              > (i.e. every time a new page is fetched from the server). In other words,
                              > multiple single-use session-ids for each session.
                              >
                              > A (single use) session id can be calculated from previos session ids and
                              > a secret shared between client and server (e.g. the password used for
                              > authentication of the user). This means that client and server must be
                              > in sync. Along with each request, the client must send the next session
                              > id that the server expects. This is why the 'back' button must not be
                              > used: the session id of the previous page would be sent to the server,
                              > but the server expects to get the session id for a new page. (I haven't
                              > worked at fixing this at the moment.)[/color]

                              I've never actually used UUCP, but one thing I've read about was the use
                              of "session counters".

                              The idea was for every dialup connection, a counter was advanced by 1 step
                              on both systems.

                              Next time the machine would connect, it would use this counter to authenticate,
                              if counters don't line up, neither could login again until someone corrected
                              the problem. (A nuisance if your visitor ever did use [Back] buttons)

                              Sounds a lot like what you're talking about.

                              Doesn't SSL have some kind of built in protection for this? I've never used it,
                              but it seems I'd heard about using SSL public key stuff for session management
                              in highly secure areas.

                              A challenge/answer is the only true way I can think of, browser sends public
                              key along with request. Server encrypts string using browsers public key and
                              sends it, next request, browser must answer previous question.

                              But it'd be really difficult to do w/out browser support.

                              Jamie
                              --
                              http://www.geniegate.com Custom web programming
                              guhzo_42@lnubb. pbz (rot13) User Management Solutions

                              Comment

                              • Gordon Burditt

                                #30
                                Re: Session theft?

                                >I've never actually used UUCP, but one thing I've read about was the use[color=blue]
                                >of "session counters".
                                >
                                >The idea was for every dialup connection, a counter was advanced by 1 step
                                >on both systems.[/color]

                                And one of the problems in practice of using it was that the counters
                                would get out of sync and require manual intervention to get the
                                connection working again.

                                There was supposed to be only a short timing window where one counter
                                but not the other was incremented, but it managed to hit that window
                                to drop modem carrier or whatever caused the out-of-sync problem
                                often enough that using session counters proved to be a real nuisance.
                                [color=blue]
                                >Next time the machine would connect, it would use this counter to authenticate,
                                >if counters don't line up, neither could login again until someone corrected
                                >the problem.[/color]

                                Gordon L. Burditt

                                Comment

                                Working...