Obviously if I am using JDBC/ODBC, I can use bind variables and prepared statements to prevent SQL injection. However, when data is passed to batch processes that end up invoking Oracle SQLPlus, is there a way to prevent SQL injection? For example:
query.sql:
select '&1' from dual;
exit;
If I call this script from SQLPlus thusly:
$ sqlplus SCOTT/TIGER @query.sql "x','y"
I will get the following output:
old 1: select '&1' from dual
new 1: select 'x','y' from dual
' '
- -
x y
As you can see, SQLPlus command line parameters are using simple macro substitution. Is there an alternative method that I am missing? Otherwise, how do I prevent this from being exploitable?