Reputation: 1
We are using a query as follows:
FROM users u INNER JOIN FETCH u.roles where u.password='" + password + "'" + " AND u.username='" + username + "'";
To prevent sql-injection, we are using regular expression to filter "username" and only allow whitelist of characters such as "^[a-zA-Z0-9]*$" and for "password" field we are using the check such as,
if(password.indexOf("'") != -1) { Sql injection attack }
Is there any ways for attackers to bypass the checks we have used to launch successful sql-injection attack?
We are using MySql v5.1
Thanks,
Upvotes: 0
Views: 124
Reputation: 51494
Seeing as it seems the moderators don't approve of me telling you to improve your code, the answer is simply "Yes, there is a flaw in the above code".
Upvotes: 1