Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeigniter session cookie is secure or not?
    primarykey
    data
    text
    <p>I'm wondering about how a user can be manipulate his cookie.</p> <p>As i know CI can know that (because the relation cookie_value/unique_key at the end of the cookie) and when happens CI renew the cookie.</p> <p>And he log this:</p> <blockquote> <p>The session cookie data did not match what was expected. This could be a possible hacking attempt</p> </blockquote> <p>The point is, some people tell about using native php session to store login data but the risk of theft is the same (and maybe less for CI cookie). The only difference i can see is user can see what data is stored in CI cookie session.</p> <p>So CI session cookie is secure or not ? Or why it is less secure than native php session ?</p> <p>I care to keep the load charge down too for a high traffic website.</p> <p>Sorry for my poor english..</p> <p><b>Edit to explain CI session validation:</b></p> <p>Assuming you <strong>do not want store sensible data</strong>, the session cookie will be not encrypted and not saved in database.</p> <p>Accordingly to CI 2.1.3 Session library, method <code>CI_Session::sess_read()</code> declared at line 135 and method <code>CI_Session::ses_write()</code> at line 235.</p> <p><b>When CI create the cookie, it put this data</b></p> <pre><code>[array] ( 'session_id' =&gt; random hash, 'ip_address' =&gt; 'string - user IP address', 'user_agent' =&gt; 'string - user agent data', 'last_activity' =&gt; timestamp ) </code></pre> <p>it serialize this array and put an md5 hash(from serialized data and the encryption key provided in config) at the end.</p> <pre><code>// if encryption is not used, we provide an md5 hash to prevent userside tampering $cookie_data = $cookie_data.md5($cookie_data.$this-&gt;encryption_key); </code></pre> <p><strong>So when the session library will be initialized from the next http request to CI</strong></p> <p>It will do and ask itself that:</p> <ol> <li>separe <code>data</code> and <code>hash</code> from the session cookie</li> <li>md5 <code>hash</code> is it equal to <code>md5( data + encryption_key )</code> ?</li> <li>Does <code>data</code> can be unserialized ?</li> <li>All the minimal data is it here ?</li> <li>this session is it expired ?</li> <li>Does IP match ?</li> <li>Does USER AGENT match ?</li> </ol> <p>If any of these answers is NO, CI session will be destroy and reset.</p> <p>So tell me please, the relative risk in addition to PHP native session for this case.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload