How do you prevent multiple clients from using the same session identifier? I ask about this because I want to add an extra layer of security to prevent session hijacking on my website. If a hacker somehow identifies a different user session identifier and makes requests with this SID, how can I find that different clients use the same SID on the server and then reject the capture attempt?
EDIT
I accepted Gumbo's answer after careful consideration, because I came to the realization that what I ask is not possible due to the limitations of the HTTP protocol without state. I forgot about what is perhaps the most fundamental principle of HTTP, and now when I think about this question it seems a little trivial.
Let me clarify what I mean:
After user A logs on to example.com, he will be given a random session identifier, for simplicity, let it be "abc123". This session identifier is stored as a cookie on the client side and verified through a server-side session to ensure that the user who is logged in remains logged in when switching from one web page to another. Of course, this cookie should not exist if HTTP was not stateless. For this reason, if user B steals user SID and creates a cookie with the value "abc123" on his computer, he successfully hijacked the session of user A, but the server simply cannot legitimately recognize that user B is different from User A's requests, and therefore the server has no reason to reject the request. Even if we must list the sessions that were already active on the server and try to find out if someone has access to an already active session, how can we determine that this is another user who is accessing the session illegally, and not the same a user who is already logged in with a session identifier, but is simply trying to make another request with it (i.e. go to another web page). We can not. Checking user agent? It can be faked, but nonetheless as good as protection in depth. IP address? It can change for legitimate reasons - but instead of not checking the IP address at all, I suggest checking something like the first two octets of IP, since even a user on the network with data that constantly changes IP for legitimate reasons will usually have only the last two octets of the IP address change.
In conclusion, stateless HTTP status condemns us for never being able to completely protect our sites from session hijacking, but good methods (like those provided by Gumbo) will be good enough to prevent the vast majority of session attacks. Attempting to protect sessions from hijacking, refusing several requests of the same SID, so it’s just ridiculous and will defeat the whole purpose of the sessions.
security php session
hesson Sep 02 2018-12-12T00: 00Z
source share