I have a C# program which does some operations on Oracle database. One of the operations - create a new account.
CREATE USER {login} IDENTIFIED BY {password}
The problem is that I can't use Parameters here, because this type of query doesn't support it. I didn't find exact documentation about why it's not supported, but I suppose it's similar to what is described here (DDL operations don't support parameters): How to use SqlCommand to CREATE DATABASE with parameterized db name?
So my question would be - how to prevent SQL injection in the following case in Oracle specifically? Should it be some regex to validate login and password? If so, what can it be? It's not clear, because, as Oracle docs says "Nonquoted identifiers cannot be Oracle SQL reserved words. Quoted identifiers can be reserved words, although this is not recommended." How can I check that my login is not ANY of reserved words? And so on.
For MS SQL I have similar situation
CREATE LOGIN {login} WITH PASSWORD=N'{password}'
and I'm solving it in the following way: I escape login with
new SqlCommandBuilder().QuoteIdentifier(name);
and password with simple
password.Replace("'", "''");
because it's a literal in the query.