I have a system that uses a Oracle database, with a schema that is different from the application user. The schema name itself is not known in advance, so we can't just hardcode it. It's a system property.
Most of the data access is through Hibernate, which can specify the default schema on connection so this is not a problem in those cases.
However, there are a few places where plain SQL queries are used (using spring jdbcTemplate). So right now we have something that boils down to:
Map<String,Object> result = jdbcTemplate.queryForMap("SELECT A, B, C FROM "+schema+".TABLE WHERE blablablah");
And this, of course, is an open SQL injection vulnerability. We're planning security audits and this will be flagged for sure.
So the question is: How do I specify the schema on the query, be it with jdbcTemplate, another Sprint data access utility, or even plain jdbc?
Thank you, JGN
set current_schemaas each session is created, either in your code of via a login trigger that recognises your application user?update("ALTER SESSION SET_CURRENT_SCHEMA=?", schemaNameFromAppProperties);which I think doesn't work with Oracle, or something like this:update("ALTER SESSION SET CURRENT_SCHEMA=" + schemaNameFromAppProperties)which will get flagged again as SQL injection vulnerability in the scan.