Hello I'm developing server with node.js and mysql. When I read some documents about mysql library, I found out that Turning multiple statements option on would increase the scope of the SQL injection attacks.
I know that if I use SQL syntax with '?' would escape the SQL syntax. So I thought that if I use the ? with using multiple query, SQL injection attack cannot be done. Is it right?
For example,
let sql = "UPDATE auth_user SET last_login=now() WHERE username=?; SELECT id, nickname FROM auth_user WHERE username = ? LIMIT 1";
let params = [username, username];
pool.getConnection(function(err, conn){
conn.query(sql, params, (err, datas, fields)=>{..}
If somebody gives "foo'; DROP TABLE auth_user;--" username params to do SQL injection, doesn't the mysql library automatically read the params as string with escaped one? Then I guessed the possibility of arising SQL injection attack would be same as the single statement is.
Why multiple statements option increase the scope of the SQL injection? How can I use multiple statements securely?