ABAP Development Standards concerning Security
You know the Secure Programming Guidelines (Link changed to release NW 70ehp3 which shows some extended content) but you want to do more?
Well, here are my top priority security recommendations for developing secure ABAP applications:
New database tables
Assign a table authorization group which enables the authorization check for the authorization object S_TABU_DIS within transactions like SE16 or SM30.
You can use the report RDDPRCHK (or RDDTDDAT_BCE) to analyze the settings.
Use transaction SM30 for view V_BRG_54 to maintain authorization groups respective view V_DDAT_54 to maintain authorization group assignments.
You can use the report RDDPRCHK (or RDDTDDAT_BCE) to analyze the settings.
Use transaction SM30 for view V_BRG_54 to maintain authorization groups respective view V_DDAT_54 to maintain authorization group assignments.
Maintain authorization groups
http://help.sap.com/saphelp_nw70/helpdata/en/a7/5134d2407a11d1893b0000e8323c4f/frameset.htm
http://help.sap.com/saphelp_nw70/helpdata/en/a7/5134d2407a11d1893b0000e8323c4f/frameset.htm
Maintain authorization group assignments
http://help.sap.com/saphelp_nw70/helpdata/en/a7/5134df407a11d1893b0000e8323c4f/frameset.htm
http://help.sap.com/saphelp_nw70/helpdata/en/a7/5134df407a11d1893b0000e8323c4f/frameset.htm
Alternate solution: If you use the authorization object S_TABU_NAM instead of S_TABU_DIS, than you can omit table authorization groups.
Set the maintenance flag which controls SE16 and SM30 correctly
Data Browser/Table View Maintenance
http://help.sap.com/saphelp_nw70/helpdata/en/a6/03883acb00d768e10000000a114084/frameset.htm
http://help.sap.com/saphelp_nw70/helpdata/en/a6/03883acb00d768e10000000a114084/frameset.htm
Activate table logging for customizing table or create a change document object for master data. You can use the report RDDPRCHK (or RDDTDDAT_BCE) to analyze the settings. Check the settings of profile parameter rec/client and the tp parameter RECCLIENT, too.
Activate/Deactivate Table Change Logging
http://help.sap.com/saphelp_nw70/helpdata/en/7e/c81ebb52c511d182c50000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw70/helpdata/en/7e/c81ebb52c511d182c50000e829fbfe/frameset.htm
Create specialized SM30 maintenance views instead of offering maintenance using SE16 and add additional authorization checks if required.
Create a Maintenance Dialog
http://help.sap.com/saphelp_nw70/helpdata/en/a1/e4521aa2f511d1a5630000e82deaaa/frameset.htm
http://help.sap.com/saphelp_nw70/helpdata/en/a1/e4521aa2f511d1a5630000e82deaaa/frameset.htm
Event 25: At the Start of the Maintenance Dialog
http://help.sap.com/saphelp_nw70/helpdata/en/c2/703037301f327ae10000009b38f839/frameset.htm
http://help.sap.com/saphelp_nw70/helpdata/en/c2/703037301f327ae10000009b38f839/frameset.htm
New transactions
Assign authorization object with appropriate field values in the definition of the transaction using transaction SE93.
Authorization Checks
http://help.sap.com/saphelp_nw70/Helpdata/en/52/67129f439b11d1896f0000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw70/Helpdata/en/52/67129f439b11d1896f0000e8322d00/frameset.htm
Enter authorization proposals using transaction SU24.
Check Indicators
http://help.sap.com/saphelp_nw70/helpdata/en/52/671470439b11d1896f0000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw70/helpdata/en/52/671470439b11d1896f0000e8322d00/frameset.htm
If the transaction is a report transaction and you have decided that the authorization check for the transaction is important: Check the authorization again using function AUTHORITY_CHECK_TCODE within the code of the report.
New BAPI / RFC Function
Ensure that application specific authorization checks are executed.
Put critical and non-critical RFC functions into separate function groups. (Well, you might assume that this is not important anymore because you can provide authorizations for S_RFC for individual functions, too, but I guess that many roles still contain authorizations for function groups.)
New Web UI
See Secure Programming Guide chapter “Secure User Interface”
http://help.sap.com/saphelp_nw70/helpdata/en/58/4d767ed850443c891ad27208789f56/frameset.htm
http://help.sap.com/saphelp_nw70/helpdata/en/58/4d767ed850443c891ad27208789f56/frameset.htm
Critical ABAP statements
Have a close look at critical ABAP statements. You can use the Code Inspector, transaction SCI, to search for such statements in custom code.
INSERT REPORT / GENERATE SUBROUTINE POOL
These statements allow to create arbitrary code. Avoid anything which would enable users to inject ABAP code.
These statements allow to create arbitrary code. Avoid anything which would enable users to inject ABAP code.
GENERATE SUBROUTINE POOL
http://help.sap.com/abapdocu_70/en/ABAPGENERATE_SUBROUTINE_POOL.htm
http://help.sap.com/abapdocu_70/en/ABAPGENERATE_SUBROUTINE_POOL.htm
CALL TRANSACTION
The statement CALL TRANSACTION does not check the authorization of the current user to execute the called transaction automatically. To do this, either the calling (preferred) or the called program must call function module AUTHORITY_CHECK_TCODE. You can replace CALL TRANSACTION by calling function ABAP4_CALL_TRANSACTION, too. This function executes all neccessary authorization checks.
The statement CALL TRANSACTION does not check the authorization of the current user to execute the called transaction automatically. To do this, either the calling (preferred) or the called program must call function module AUTHORITY_CHECK_TCODE. You can replace CALL TRANSACTION by calling function ABAP4_CALL_TRANSACTION, too. This function executes all neccessary authorization checks.
CALL ‘SYSTEM’
This statement sends operation system commands to the application server which are then executed by the powerfull user
This statement sends operation system commands to the application server which are then executed by the powerfull user
Generic functionality
Avoid developing generic functionality which enables the user to choose any target table, file, report or transaction. Have a close look to these statements:
- Generic access to tables using SELECT … FROM (variable)
http://help.sap.com/abapdocu_70/en/ABAPFROM_CLAUSE.htm - Generic access to files using OPEN DATASET variable
http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET.htm - Generic execution of reports using SUBMIT (variable)
http://help.sap.com/abapdocu_70/en/ABAPSUBMIT.htm - Generic execution of transactions using CALL TRANSACTION variable
http://help.sap.com/abapdocu_70/en/ABAPCALL_TRANSACTION.htm
Other blogs:
- Secure Execution of OS Commands by ABAP programs from Patrick Hildenbrand
- Protecting ABAP code against Directory Traversal Attacks from Patrick Hildenbrand
- How to put proper authority-checks to your custom programs from Otto Gold
Code Scanning for vulnerabilities
Knowing about the rules for developing secure software is one part of the game. The other is to search for security vulnerabilities in existing code and to prevent to introduce security vulnerabilities while developing new code.
For several years you could have used the Code Profiler from partner Virtual Forge. SAP consulting offers a service to scan your ABAP code using that tool as well (seen note 1531056).
Since 2013, SAP offers a security code scanner as part of the develpment workbench. The add-on tool is called
SAP NetWeaver Application Server, add-on for code vulnerability analysis
(short name: code vulnerability analyzer)
Here are some links for further reading:
- Article on SAPinsider
- WIKI on SCN
- Blog with example on SCN
- ABAP Keyword Documentation
- Teched 2013 workshop SIS261
Kind regards
Frank Buchholz
Active Globas Support – Security Services
Thanks a lot for this nice summary about important security issues.
The statment CALL TRANSACTION can be replaced by calling fm ABAP4_CALL_TRANSACTION which does the authority check.
Regards
Uwe
Frank,
I would like to comment on your suggestion about activating table logging for customizing tables. In my opinion this is a particularly valuable action if GRC Access Control Emergency Access Management is in use or in your future plans, so that your "firefighter" logs will provide the details that reviewers will expect to see.
Thanks for the excellent reminders!
Gretchen