Can cookie vars be edited by user?

Discussion in 'PHP' started by Tony Brar, Oct 31, 2012.

  1. #1
    Hi guys,

    Can a $COOKIE[] var be edited by user?
    If it can, I have quite a security issue to deal with. :)

    Thanks,
    -Tony
     
    Solved! View solution.
    Tony Brar, Oct 31, 2012 IP
  2. #2
    YES it is possible.
     
    plussy, Oct 31, 2012 IP
  3. Tony Brar

    Tony Brar Active Member

    Messages:
    220
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #3
    Okay. I have some security holes to patch.
    :rolleyes:
     
    Tony Brar, Oct 31, 2012 IP
  4. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #4
    Yep, with most modern browsers that support plugins. There are plenty of plugins that can change the content of cookies :) so its a risk!
     
    EricBruggema, Oct 31, 2012 IP
  5. Tony Brar

    Tony Brar Active Member

    Messages:
    220
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #5
    If that's the case, can session vars be edited as well?
     
    Tony Brar, Nov 1, 2012 IP
  6. plussy

    plussy Peon

    Messages:
    152
    Likes Received:
    5
    Best Answers:
    9
    Trophy Points:
    0
    #6
    yes and no.

    Sessions are basically cookies with the difference that the data is stored on the server. In order to link the user to a session a session cookie is placed on the users computer with one long string in it. This string is a random generated string and is called session id. With this session id the server knows what data has been stored in the session.

    Now a user can edit the session id in the session cookie but if there is no session with that session id on the server no data will be loaded from the session.

    You would have to be extremely lucky to change the session id to someone elses session id. But if you can do it then you can steal a session and get access to the other users account etc. There are other things you can do to stop this like store the ip or the browser and if something changes simply delete the whole session.

    Also sessions time out after a while but you have a little bit control over that if you search a bit.

    hope this helped.
     
    plussy, Nov 1, 2012 IP
  7. Tony Brar

    Tony Brar Active Member

    Messages:
    220
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #7
    thanks.
    good answer.
     
    Tony Brar, Nov 1, 2012 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #8
    Really good browsers like Opera even have it built in. Right click, "edit site preferences", "cookies"

    Along with all the other built in per-site preferences like plugin blocking, script blocking, user.css, pretending to be other browsers when some idiot wrote broken browser sniffing scripts...
     
    deathshadow, Nov 1, 2012 IP
  9. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #9
    You can use an encryption schema to secure the data in the cookie from being reasonably manipulated by the user. Using AES or rijndael cipher would effectively prevent manipulation and wouldn't cause an enormous amount of overhead to an average request. However, this is pretty excessive overkill for the purpose of using a cookie.

    I'd be open to hearing the argument in preventing a user from seeing or manipulating cookie data, but it's not meant for storage of sensitive information so don't use it for that purpose.

    If you can give some more info on what your trying to accomplish and what your concerns are, I think the members could give some input on the best way to accomplish it.
     
    jestep, Nov 2, 2012 IP
  10. shubhamm

    shubhamm Member

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #10
    it's possible by a cookie editor or any other editor

    For example you can edit cookie in Friefox by cookie editor addon or by open which comes with inbuilt cookie editor
     
    shubhamm, Nov 3, 2012 IP