Custom ABAP code runs inside the system that holds an organisation's finance, HR and supply chain data, so a single missing authority check or unescaped dynamic statement can expose far more than a typical web application bug. SAP's authorisation concept only protects data when programs actually ask it the right question, and SAP's own security notes for ABAP state that most risks come from external input used in dynamically specified statements. This guide covers explicit authority checks, injection classes in ABAP (Open SQL, native SQL, ABAP command, call, OS command, directory traversal and cross-site scripting), RFC-enabled function modules and callbacks, what the Security Audit Log records about code and debugging, and how to enforce all of it with the Code Vulnerability Analyzer in the ABAP Test Cockpit. It is written for ABAP developers, development leads and the security teams that review custom code and transports. For system-level settings, see the SAP NetWeaver and S/4HANA Basis Hardening Guide.
This is an independent guide from NHI Mgmt Group, based on SAP's public documentation as of November 2026. It is not sponsored or reviewed by SAP. Product features change, so confirm settings against SAP's current documentation.
Key takeaways
- Authorisation is the developer's job in custom code. Transaction start checks protect entry points, but any report, function module or method that reads or changes business data needs an explicit
AUTHORITY-CHECKwithsy-subrcevaluated straight after it. - Static Open SQL removes most injection risk. Use dynamic WHERE, SET, GROUP BY, HAVING or table names only when genuinely needed, and then validate with
CL_ABAP_DYN_PRGmethods such asquote,check_column_nameandcheck_whitelist_str. - Every RFC-enabled function module is a network API. Treat its parameters as untrusted input, check business authorisation inside the module, and keep RFC callback whitelists active with
rfc/callback_security_methodset to 3. - Back doors hide in dynamic code. Hard-coded user names,
INSERT REPORT,GENERATE SUBROUTINE POOLand dynamic calls are where static checks reach their limit, so SAP recommends code inspections under a four-eyes principle. - Make security checks a release gate. Run the Code Vulnerability Analyzer through the ABAP Test Cockpit, block transport release on open findings, and manage exemptions as reviewed, recorded decisions.
How identity and access work in custom ABAP
An ABAP program always runs as the logged-on user (sy-uname), whether that user is a dialog user, a background job step user or an RFC communication user. The user's roles and profiles carry authorisations for authorisation objects, each with up to ten fields such as ACTVT (activity), company code or plant. The kernel checks some of these implicitly, for example the start authorisation for a transaction (object S_TCODE) and the transaction's own check object maintained in SE93. Everything else is checked only if the program asks.
The AUTHORITY-CHECK statement: the program names the object with OBJECT and passes each field with ID ... FIELD .... DUMMY skips a field, and only elementary values are accepted, not selection tables. SAP documents return code 0 as authorised; any non-zero value means the user lacks the authorisation for the values given, the field count was wrong or the object is unknown. Code must treat every non-zero value as a denial.
Check does not mean filter: SAP Learning stresses that AUTHORITY-CHECK does not filter data. If a SELECT runs before or without the check, the user sees the rows. On current releases, reading through CDS views with CDS access controls filters rows automatically, and an explicit check is still useful to tell "not authorised" apart from "does not exist".
| Access path | What the platform checks | What custom code must add |
|---|---|---|
| Transaction start | S_TCODE plus the SE93 check object | Checks on the data actually read or changed (organisational level, activity) |
LEAVE TO TRANSACTION | Start authorisation checked implicitly | Nothing extra for the start; data checks in the target |
CALL TRANSACTION | Checked only with the WITH AUTHORITY-CHECK addition (release 7.40 and later) | Use the addition; the variant without it is flagged as obsolete |
SUBMIT of a report | Program authorisation group if maintained | Data checks in the submitted report |
| RFC-enabled function module | S_RFC on the calling user for the function group or module | Business authorisation checks on the parameters received |
| CDS view with access control | Row filtering by the DCL role | Explicit check for actions, not only reads |
Admin roles and privileged code paths
Some ABAP features let code, or a developer, step outside normal authorisation. They deserve their own review list.
- Hard-coded user names: conditions such as
IF sy-uname = 'JSMITH'are classic back doors and also break when people move roles. The Code Vulnerability Analyzer flags them (check 0821). SAP's community guidance also warns that the same logic can be disguised, for example by assigningsy-unameto a field symbol, which tools may miss. - Generated and inserted code:
INSERT REPORTandGENERATE SUBROUTINE POOLcreate executable code at runtime (checks 1108, 1111). Keep them out of business code, and where a framework needs them, generate only from fixed templates, never from input. - Remote code installation: the function module
RFC_ABAP_INSTALL_AND_RUNruns supplied source code (check 1109). RestrictS_RFCaccess to it at role level and never wrap it in custom RFC modules. - Debugging with replace: changing field contents in the debugger (Security Audit Log event CUL) or jumping into the debugger (CU_M) can bypass any check in the code. Keep debug change authorisation in
S_DEVELOPout of production roles except emergency access. - Deleting or overwriting repository objects: checks 1110 and 1111 flag deletion of important reports and overwriting via
INSERT REPORT, both integrity risks. - Authorisation defaults: maintain proposals for custom transactions in SU24 so role designers get the objects the code really checks, instead of granting wide values to make a program run. See the Segregation of Duties Guide for the role-design side.
Injection and dynamic programming
SAP's security notes list six risk areas for input from outside: SQL injection, dynamic calls, directory traversal, system command injection, cross-site scripting and ABAP command injection. The common rule is to check and mask all external input before it is used in a dynamically specified statement, including cases the documentation does not list, such as dynamic WHERE conditions on internal tables. "External" includes selection-screen input, RFC and HTTP parameters, file contents and values read from tables that users can maintain.
| Risk | Typical ABAP construct | Preferred fix | CVA checks |
|---|---|---|---|
| Open SQL injection | Dynamic WHERE, SET in UPDATE, column list, GROUP BY, HAVING, table name; CREATE_QUERY filter in Object Services | Static Open SQL; else CL_ABAP_DYN_PRG=>quote, check_column_name, check_table_name_str, check_whitelist_str | 1101, 110A, 110B, 1112, 1114, 1116, 1117, 1118, 1120, 1122 |
| Native SQL injection | ADBC statements built by concatenation | Avoid ADBC for user-driven queries; bind values with parameters | 1128 (DDL), 1130 (DML) |
| Secondary connection misuse | Connection name taken from input | Fixed, configured connection names only | 1121 |
| ABAP command injection | INSERT REPORT, GENERATE SUBROUTINE POOL, RFC_ABAP_INSTALL_AND_RUN | No generation from input; fixed templates only | 1108, 1109 |
| Call injection | Dynamic CALL FUNCTION via RFC, SUBMIT, CALL TRANSACTION, LEAVE TO TRANSACTION | Allow list of permitted targets; WITH AUTHORITY-CHECK on calls | 1140 to 1144 |
| OS command injection | FILTER addition of OPEN DATASET | Do not use FILTER; use configured external commands (SM69) called through the standard function modules | 1106, 1107 |
| Directory traversal | File names in OPEN DATASET or DELETE DATASET, CL_ABAP_FILE_UTILITIES, FILE_GET_NAME | Logical file names and paths (FILE transaction) with validation; never raw paths from input | 1104, 1124, 1126 |
| Cross-site scripting | BSP, HTMLB or HTML controls writing input into pages | Built-in escape function with the right format; forceEncode on htmlb:content; drop obsolete escape methods | 1132, 1134, 1135, 1150, 1151, 1152 |
Quoting correctly: SAP's guidance shows a dynamic WHERE built from user input returning every row of a table. CL_ABAP_DYN_PRG=>quote wraps the value in single quotes and escapes embedded quotes, so the input stays one literal; community guidance from SAP prefers it over escape_quotes because it removes doubt about who adds the outer quotes. Numeric values do not need quoting but should be typed as numbers, not strings. For identifiers (columns, tables), quoting is the wrong tool: validate against the dictionary or an allow list.
For language-neutral background on each class, see the SQL Injection Prevention Guide, Path Traversal Guide, Command Injection Guide and Cross-Site Scripting (XSS) Prevention Guide.
Integrations, API tokens and service accounts
RFC is the main machine-to-machine interface into ABAP systems, and the callers are almost always non-human: communication users for middleware, interface partners and other SAP systems. Code is where these identities either stay narrow or become a route to everything.
- Treat remote-enabled modules as public APIs.
S_RFCdecides which function groups or modules a caller may start; it does not decide which company code or document the caller may touch. AddAUTHORITY-CHECKstatements on the business objects inside each custom RFC module, and validate every importing parameter. - Never take a function name from a caller. Dynamic function calls driven by UI or RFC input are flagged by check 1144. Map an input code to a fixed list of modules instead.
- Keep credentials out of source. Outbound connections belong in SM59 RFC destinations or HTTP destinations with stored logon data or trust relationships, maintained by Basis, not literals in code or custom tables.
- Lock down callbacks. A synchronous RFC can call back into the caller through destination
BACK. SAP documents four values forrfc/callback_security_method: 0 ignores whitelists, 1 (the default) rejects only callbacks blocked by active whitelists, 2 also logs callbacks that would be blocked by inactive whitelists, and 3 rejects callbacks blocked by active or inactive whitelists. Maintain the whitelist per destination in SM59 (Logon and Security, Callback whitelist), run value 2 to learn, then move to 3. - Reduce the callable surface. Unified Connectivity (UCON) collects which RFC modules are really used and blocks the rest from external callers, and its Role Builder scenario helps build narrow roles for RFC users.
Communication users are non-human identities with long-lived passwords or certificates. See the SAP BTP Security Guide for cloud-side destinations and the How to Run an Access Review for Service Accounts for review practice.
Logging and detection
The Security Audit Log is configured in SM19 or RSAU_CONFIG and read in SM20 or RSAU_READ_LOG. Since release 7.40, kernel parameters set in those transactions override profile parameters such as rsau/enable, while DIR_AUDIT and FN_AUDIT still set the file location. SAP's recommended baseline filters log all critical events for all users and clients, everything for SAP*, and support and emergency users.
| Event | Meaning | Why a code reviewer cares |
|---|---|---|
| CUL | Field content changed in the debugger | Bypasses any authority check in the code |
| CU_M | Jump into the ABAP debugger | Precursor to CUL in production |
| BUZ | Program, line and event of a debugger change | Shows which check was bypassed |
| BU4 | Dynamic ABAP code inserted, generated or deleted | Detects runtime code generation outside expected frameworks |
| AUK, AUL | Successful and failed RFC function calls | Shows which modules communication users really call |
| AU5, AU6 | Successful and failed RFC logons | Credential misuse by interface users |
| CUZ, DU9 | Generic table access through RFC and generic table access | Data extraction that bypasses application checks |
| DUI, DUJ, DUK | RFC callback performed, rejected, simulated | Evidence for moving the callback parameter to 3 |
AUK is high volume, so SAP's guidance suggests logging successful RFC calls for limited periods (for example while building UCON and role allow lists) and failed events permanently. Restrict access to the log itself to Basis and security staff and set retention with data protection in mind. Forward events to the SOC platform with the program name and user type so analysts can tell a dialog user from a communication user.
Hardening baseline for custom code
The Code Vulnerability Analyzer (CVA) performs static data flow analysis on ABAP and is embedded in the extended program check (SLIN, shown as "Security Analyses in Extended Program Check (SLIN_SEC)"), the Code Inspector (SCI) and the ABAP Test Cockpit (ATC). SAP recommends running the security checks through ATC. It is licensed separately; once licensed, report RSLIN_SEC_LICENSE_SETUP enables the checks system-wide (SAP Notes 1921820 and 1949276 list availability and restrictions).
- Baseline: run a full ATC mass run with the security checks on all custom namespaces (Z*, Y* and registered namespaces) in a development or quality system. Sort findings by check number into injection, authorisation and integrity groups.
- Register wrappers: if your code wraps vulnerable statements in reusable methods, register them with BAdI
SLIN_BADI_VULN_PROCEDURESso data flow through them is followed. ReportsRSLIN_SEC_DISPLAY_VULN_PROCandRSLIN_SEC_DISPLAY_BADISshow what is registered and which data sources count as secure. - Fix forward first: new and changed code must be clean before old findings are tackled. Configure ATC in the transport release process so transports with priority 1 security findings cannot be released.
- Exemptions as decisions: where a finding is not exploitable and a change is not worthwhile, request an ATC exemption with a written reason and an approver who is not the developer. Some checks, such as
CALL TRANSACTIONon older releases, need an exemption to suppress the message. - Four-eyes review of the rest: back doors in dynamic code are beyond static checks, so peer review every change that touches dynamic statements, generated code or authorisation logic. The Secure Code Review Checklist gives a general structure.
- Remediate the legacy backlog by exposure: RFC-enabled and HTTP-exposed code first, then reports with dynamic SQL on sensitive tables, then the rest.
- Roll back safely: fixes to authority checks can block legitimate users. Test with users holding narrow and missing authorisations (SU53 shows the failed check), deploy in a quality system with real roles, and keep the previous transport version ready to re-import.
Apply SAP Security Notes promptly: SAP publishes them on Security Patch Day, the second Tuesday of every month, through SAP for Me.
Measuring progress
- Open priority 1 CVA findings in custom code, trended monthly, split by check group.
- Share of transports released with a passing ATC security run (target 100 percent).
- Active exemptions with a reason, approver and review date, and their age.
- Custom RFC modules without an explicit business authority check (from review or CVA checks 1160 and 114x).
- Debugger change events (CUL) in production outside emergency access sessions (target zero).
Framework mapping
| Framework | Reference | How this guide applies it |
|---|---|---|
| NIST SP 800-53 Rev 5 | SA-11 Developer Testing and Evaluation; SA-15 Development Process, Standards, and Tools | CVA in ATC as a mandatory gate; documented exemption process |
| NIST SP 800-53 Rev 5 | SI-10 Information Input Validation | CL_ABAP_DYN_PRG, allow lists, logical file names |
| NIST SP 800-53 Rev 5 | AC-3 Access Enforcement; AC-6 Least Privilege | Explicit AUTHORITY-CHECK, narrow RFC roles, UCON |
| NIST SP 800-53 Rev 5 | AU-2 Event Logging; CM-3 Configuration Change Control | Security Audit Log events; transport release gate |
| NIST CSF 2.0 | PR.PS-06 Secure software development practices | Secure coding rules and monitored checks across the ABAP lifecycle |
| ISO/IEC 27001:2022 Annex A | 8.28 Secure coding; 8.29 Security testing in development and acceptance | Coding rules above; ATC runs before transport |
| CWE | CWE-89, CWE-78, CWE-22, CWE-79, CWE-94, CWE-862, CWE-798 | SQL, OS command, path, XSS, code injection, missing authorisation, hard-coded credentials |
| MITRE ATT&CK | T1190 Exploit Public-Facing Application | Injection in HTTP- or RFC-exposed custom code |
See the CWE Top 25 Guide for how these weaknesses rank across languages.
Common misconfigurations
- Checking but not acting: an
AUTHORITY-CHECKfollowed by code that ignoressy-subrc, or reads the data first and checks afterwards. CVA check 1160 catches the first; code review catches the second. - Relying on the transaction code alone: a custom report protected only by
S_TCODEthat then lists every company code. Add organisational-level checks in the code and SU24 proposals for role designers. - Generic table browsers in custom code: utilities that take a table name and WHERE clause from the screen or an RFC caller. They combine checks 1118 and 1101 with no data authorisation; remove them or restrict to fixed tables with
S_TABU_NAMchecks. - RFC modules written for one partner and reused by many: a module designed for a trusted middleware user is later exposed to more callers through wide
S_RFCvalues. Add business checks inside the module and keep UCON allow lists current. - Escaping with the wrong method: obsolete HTML escape methods (check 1150) or
escape_quoteswithout the surrounding quotes, leaving injection open. Usequotefor SQL literals and the built-inescapefunction with the correct format for HTML, JavaScript or URLs. - Exemptions with no owner: ATC exemptions granted to unblock a go-live and never reviewed. Give each one an expiry and review it with the security team.
Practitioner checklist
- Every custom program that reads or changes business data has an explicit
AUTHORITY-CHECKbefore the data access, with all non-zerosy-subrcvalues treated as denial. CALL TRANSACTIONusesWITH AUTHORITY-CHECK; dynamic call targets come from an allow list.- Dynamic Open SQL is used only where static SQL cannot work, with
CL_ABAP_DYN_PRGvalidation on every external value. - No
FILTERaddition onOPEN DATASET; file access uses logical file names. - No hard-coded user names, credentials or runtime code generation from input in custom code.
- Custom RFC modules validate parameters and check business authorisation; outbound credentials live in SM59 destinations.
rfc/callback_security_methodis 3 after a simulation period at 2, with callback whitelists per destination.- CVA runs in ATC on every transport, priority 1 findings block release, and exemptions have a reason, approver and expiry.
- Security Audit Log captures debugger changes, dynamic code events and failed RFC calls, forwarded to the SOC.
- Changes to dynamic code and authorisation logic get a four-eyes review.
Standards and references
- SAP: ABAP Keyword Documentation, Security Notes for Dynamic Programming
- SAP: Authorization Checks in ABAP Programs
- SAP Learning: Using the AUTHORITY-CHECK Statement
- SAP Community: Code Vulnerability Analyzer Checks
- SAP Community: How to Protect Your ABAP Code Against SQL Injection Attacks
- SAP Community: RFC Callback Whitelist
- SAP Community: Analysis and Recommended Settings of the Security Audit Log
- SAP: Unified Connectivity (UCON)
Related NHI Mgmt Group resources: SAP NetWeaver and S/4HANA Basis Hardening Guide, Secure Code Review Guide, SAST Triage Guide, OWASP Top 10 A01 Guide.