SAP OBSCURE CODE SCRTY
Get Example source ABAP code based on a different SAP table
Obscuring ABAP Source Code
In general, any type of obscured code presents a security risk. Instead of bypassing static checks by using obscured code, false positives should be handled using other methods, such as exemptions. Obscured code can often only be detected using a two-man rule (code inspections).
Example ABAP Coding
Maliciously obscured code in a
ASSIGN (field) TO FIELD-SYMBOL( < field>).
...
IF < field> = `...`.
...
ENDIF.>
ABAP_EXAMPLE_END
Example ABAP Coding
Code obscured without malicious intent. In a HTTP request handler, a HTML file is created by calling a method in which potential
DATA(html) = cl_demo_html_provider=>get( ).
'XSS is prevented in cl_demo_html_provider
DATA(html_name) = `HTML`.
ASSIGN (html_name) TO FIELD-SYMBOL( < html>).
server->response->set_cdata( data = < html> ).
ENDMETHOD.>
The correct form of the HTTP request handler would be:
DATA(html) = cl_demo_html_provider=>get( ).
'XSS is prevented in cl_demo_html_provider
server->response->set_cdata( data = html ).
ENDMETHOD.>
If the security check raises a false positive, either an exemption or an improvement to the check should be requested.
ABAP_EXAMPLE_END