SQL injection on INSERT

Injection can happen on any SQL statement not run properly. For example, let’s pretend your comment table has two fields, an integer ID and the comment string. So you’d INSERT as follows: INSERT INTO COMMENTS VALUES(122,’I like this website’); Consider someone entering the following comment: ‘); DELETE FROM users; — If you just put the … Read more

Prevent SQL injection attacks in a Java program

You need to use PreparedStatement. e.g. String insert = “INSERT INTO customer(name,address,email) VALUES(?, ?, ?);”; PreparedStatement ps = connection.prepareStatement(insert); ps.setString(1, name); ps.setString(2, addre); ps.setString(3, email); ResultSet rs = ps.executeQuery(); This will prevent injection attacks. The way the hacker puts it in there is if the String you are inserting has come from input somewhere – … Read more

Does CodeIgniter automatically prevent SQL injection?

CodeIgniter DOES ESCAPE the variables you pass by when using the $this->db->query method. But ONLY when you pass the variables as binds, here’s an example: $dbResult = $this->db->query(“SELECT * FROM users WHERE username = ?”, array($this->input->post(‘username’))); Also remember that $_POST shouldn’t be preferred over $this->input->post since what it does is check if the variables exists … Read more

Non-web SQL Injection

If you’re building SQL in your macro, it’s vulnerable to SQL injection. Even if you trust the people who will be using the thing, you should at least watch for the basics, like people trying to put single-quote and semicolon characters into database fields. this isn’t so much a security issue in your case as … Read more

Why is using a mysql prepared statement more secure than using the common escape functions?

An important point that I think people here are missing is that with a database that supports parameterized queries, there is no ‘escaping’ to worry about. The database engine doesn’t combine the bound variables into the SQL statement and then parse the whole thing; The bound variables are kept separate and never parsed as a … Read more