Avoid dynamically constructing SQL queries
Hello all,
We are scanning the CF files using Veracode software, and after scanning: Veracode returns some of the files that need to be address the
dynamically constructing SQL queries. The below codes is dynamically constructing SQL queries.
<cfquery name="qBprfp490" datasource="Hobbes">
SELECT mprno
FROM #aPacket[1]#.bprfp490
WHERE mprnoa = <cfqueryparam value="#aValue#" cfsqltype="cf_sql_varchar" >
</cfquery>
I think by placing aValue inside the <cfqueryparam> tag will resolve the SQL injection. But I think it requires me to fix the line that starts with the word "FROM"
The below is the instructions from Veracode regarding how to avoid dynamically constructing SQL queries
"Avoid dynamically constructing SQL queries. Instead, use parameterized prepared statements to prevent the
database from interpreting the contents of bind variables as part of the query. Always validate untrusted input to
ensure that it conforms to the expected format, using centralized data validation routines when possible"
Any advise how to fix dynamically constructing SQL queries please
Thanks
HP.
