security - Can you "SQL Inject" a PHP Variable Comparison? -
While working on an existing project, I am thinking of something when a simple variable comparison attacks "SQL injection" type attacks A user is entered.
My basic login feature works by using a statement prepared by the user in the given username and profile table. If any records have been found, then profile ID
is received from the record and is used to view the user's password in any other permission table. If this query is successful then the password provided by the user is ===
with the password retrieved from the database.
So my question is, does a risk occur in the final phase? I have tried hacking it, like a '==' a '|| In an attempt to trigger the wrong way '
$ pass === $ checkPermRow [' pass']
but nothing seems to happen if you use the prepared statement and Ready to pass input as the parameter of the statement, are you safe?
Therefore it should not be possible to inject anything into the query. However, you should not keep the password in plain text, but should not use the proper hash function in an irreversible form as a hash.
For your question whether injection is also possible in PHP: Yes, code injection can occur in any code that is dynamically generated, even in PHP as well.
However, you just do not need to dynamically generate codes, but it must also be executed. PHP has some functions that execute PHP), e. Yes, however, you probably will not use such construction:
if (eval ("return '$ pass' === '$ checkPermRow [pass]'))") )
It will be weak and a a '==' a '|| 'A' will result in something like this:
returns 'a' == 'A' || 'A' === 'Password from database';
Comments
Post a Comment