EchoFool Posted July 11, 2010 Share Posted July 11, 2010 Can users edit their cookie/session and thus change who they are logged in as on a website? If they changed the data from say user 1 to user 2 would it work if so how is it done? And how is it prevent on the server side ? thanks Quote Link to comment https://forums.phpfreaks.com/topic/207391-can-sessions-be-edited/ Share on other sites More sharing options...
xcasio Posted July 11, 2010 Share Posted July 11, 2010 They can't change session data, but they can easily spoof cookie data. Quote Link to comment https://forums.phpfreaks.com/topic/207391-can-sessions-be-edited/#findComment-1084266 Share on other sites More sharing options...
EchoFool Posted July 11, 2010 Author Share Posted July 11, 2010 explain spoof? Quote Link to comment https://forums.phpfreaks.com/topic/207391-can-sessions-be-edited/#findComment-1084267 Share on other sites More sharing options...
PFMaBiSmAd Posted July 11, 2010 Share Posted July 11, 2010 The only ways that someone could set a session variable to a specific value is if your code allows it or register_globals are on. Do you have a specific problem you are trying to solve? Quote Link to comment https://forums.phpfreaks.com/topic/207391-can-sessions-be-edited/#findComment-1084268 Share on other sites More sharing options...
EchoFool Posted July 11, 2010 Author Share Posted July 11, 2010 no im just checking such a problem could not happen for example.... when a user registers or logs in $_SESSION['Current_User'] = 4; lets say ID 4. Then i use that ID for everything. But if some one can edit their SESSION via their browser with a cookie editor, then they could set their ID as one of the Admins and thus have staff permissions and appear to be logged in as one of the staff members. So wanted to make sure that could not happen. And if it could how is it preventable. Quote Link to comment https://forums.phpfreaks.com/topic/207391-can-sessions-be-edited/#findComment-1084271 Share on other sites More sharing options...
ChemicalBliss Posted July 11, 2010 Share Posted July 11, 2010 Sessions have uniquely generated Keys, only this key is passed to the user via either the URL, or a COOKIE. These keys, depending on the amount of Users visiting your page is extremely difficult to guess. Some light reading: http://phpsec.org/projects/guide/4.html http://www.sitepoint.com/blogs/2004/03/03/notes-on-php-session-security/ The answers on this page can give some good information if your really interested: http://stackoverflow.com/questions/138670/how-unique-is-the-php-session-id -cb- Quote Link to comment https://forums.phpfreaks.com/topic/207391-can-sessions-be-edited/#findComment-1084272 Share on other sites More sharing options...
EchoFool Posted July 11, 2010 Author Share Posted July 11, 2010 By saying : extremely difficult Means the possibility can occur? Quote Link to comment https://forums.phpfreaks.com/topic/207391-can-sessions-be-edited/#findComment-1084274 Share on other sites More sharing options...
ChemicalBliss Posted July 11, 2010 Share Posted July 11, 2010 Of course, read those articles i posted it will tell you everything you need to know. -cb- Quote Link to comment https://forums.phpfreaks.com/topic/207391-can-sessions-be-edited/#findComment-1084277 Share on other sites More sharing options...
.josh Posted July 11, 2010 Share Posted July 11, 2010 yes it is possible. It is called session hijacking. Session variable names and their values are stored on the server in a temporary file. When you start a session, a unique key - an id - is created (by default it is randomly generated, though you can specify what the id is if you want to). This key (id) is stored in a cookie on the user's computer. If cookies are disabled, it is possible to pass the session key (id) as a url parameter instead. It is not possible to directly access a session variable or its value, because it is stored on the server. What happens with session hijacking is someone changes the session key (id) cookie value to another value that matches someone else's session key (id). Virtually every browser out there makes it super easy to alter cookie values via built-in developer tools or addons. Also it's really not that hard to just edit the cookie file directly. Or specifies it in the url when making a request to the server, which is as easy as just entering in the appended url into your browser url box and pressing the go button. This is why when you are on a public or shared computer, it is a good idea to clear your cookies, history etc.. before leaving. Yes, if someone guesses another user's session key (id) they can send that key in their next request and be logged in as that user. This is why most sites do not show particularly sensitive account information, even within account settings (like credit card numbers, ss numbers, passwords, etc...), and also prompt for info before changing key information (like prompting for old pw to change your pw, etc...). Quote Link to comment https://forums.phpfreaks.com/topic/207391-can-sessions-be-edited/#findComment-1084282 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.