SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP - Security Notes → Security Risks in Dynamic Programming → SQL Injections →SQL Injections Using Object Services
Filter conditions are passed to a query as character strings in the query service in the Object Services If a filter condition like this (or part of it) originates outside the program, the same risk of an SQL injection is incurred as when a dynamic WHERE condition is manipulated in Open SQL. To prevent SQL injections of this nature, either parameters from a parameter list or must be used or dynamic parts escaped using the class CL_ABAP_DYN_PRG.
Example
The example program DEMO_QUERY_SERVICE is secure, since the interactive input is passed to the query using parameter bindings. If the source code after the statement TRY is replaced as follows, however, SQL injections are possible:
If airpfrom and airpto contain the values "FRA' OR AIRPFROM <> '" and "SIN' OR AIRPTO <> '", for example, all existing data is read. If no parameter bindings are used, therefore, airpfrom and airpto must be escaped.