Join our Newsletter — 33% off our NHI Course
Home› Guides› SAP ABAP Secure Coding Guide: Authority Checks, Injection…
Guide Application Security

SAP ABAP Secure Coding Guide: Authority Checks, Injection and Safe RFC

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 14 November 2026 16 min read
On this page

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-CHECK with sy-subrc evaluated 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_PRG methods such as quote, check_column_name and check_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_method set to 3.
  • Back doors hide in dynamic code. Hard-coded user names, INSERT REPORT, GENERATE SUBROUTINE POOL and 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 pathWhat the platform checksWhat custom code must add
Transaction startS_TCODE plus the SE93 check objectChecks on the data actually read or changed (organisational level, activity)
LEAVE TO TRANSACTIONStart authorisation checked implicitlyNothing extra for the start; data checks in the target
CALL TRANSACTIONChecked 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 reportProgram authorisation group if maintainedData checks in the submitted report
RFC-enabled function moduleS_RFC on the calling user for the function group or moduleBusiness authorisation checks on the parameters received
CDS view with access controlRow filtering by the DCL roleExplicit 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 assigning sy-uname to a field symbol, which tools may miss.
  • Generated and inserted code: INSERT REPORT and GENERATE SUBROUTINE POOL create 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_RUN runs supplied source code (check 1109). Restrict S_RFC access 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_DEVELOP out 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.

RiskTypical ABAP constructPreferred fixCVA checks
Open SQL injectionDynamic WHERE, SET in UPDATE, column list, GROUP BY, HAVING, table name; CREATE_QUERY filter in Object ServicesStatic Open SQL; else CL_ABAP_DYN_PRG=>quote, check_column_name, check_table_name_str, check_whitelist_str1101, 110A, 110B, 1112, 1114, 1116, 1117, 1118, 1120, 1122
Native SQL injectionADBC statements built by concatenationAvoid ADBC for user-driven queries; bind values with parameters1128 (DDL), 1130 (DML)
Secondary connection misuseConnection name taken from inputFixed, configured connection names only1121
ABAP command injectionINSERT REPORT, GENERATE SUBROUTINE POOL, RFC_ABAP_INSTALL_AND_RUNNo generation from input; fixed templates only1108, 1109
Call injectionDynamic CALL FUNCTION via RFC, SUBMIT, CALL TRANSACTION, LEAVE TO TRANSACTIONAllow list of permitted targets; WITH AUTHORITY-CHECK on calls1140 to 1144
OS command injectionFILTER addition of OPEN DATASETDo not use FILTER; use configured external commands (SM69) called through the standard function modules1106, 1107
Directory traversalFile names in OPEN DATASET or DELETE DATASET, CL_ABAP_FILE_UTILITIES, FILE_GET_NAMELogical file names and paths (FILE transaction) with validation; never raw paths from input1104, 1124, 1126
Cross-site scriptingBSP, HTMLB or HTML controls writing input into pagesBuilt-in escape function with the right format; forceEncode on htmlb:content; drop obsolete escape methods1132, 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.

  1. Treat remote-enabled modules as public APIs. S_RFC decides which function groups or modules a caller may start; it does not decide which company code or document the caller may touch. Add AUTHORITY-CHECK statements on the business objects inside each custom RFC module, and validate every importing parameter.
  2. 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.
  3. 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.
  4. Lock down callbacks. A synchronous RFC can call back into the caller through destination BACK. SAP documents four values for rfc/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.
  5. 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.

EventMeaningWhy a code reviewer cares
CULField content changed in the debuggerBypasses any authority check in the code
CU_MJump into the ABAP debuggerPrecursor to CUL in production
BUZProgram, line and event of a debugger changeShows which check was bypassed
BU4Dynamic ABAP code inserted, generated or deletedDetects runtime code generation outside expected frameworks
AUK, AULSuccessful and failed RFC function callsShows which modules communication users really call
AU5, AU6Successful and failed RFC logonsCredential misuse by interface users
CUZ, DU9Generic table access through RFC and generic table accessData extraction that bypasses application checks
DUI, DUJ, DUKRFC callback performed, rejected, simulatedEvidence 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).

  1. 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.
  2. Register wrappers: if your code wraps vulnerable statements in reusable methods, register them with BAdI SLIN_BADI_VULN_PROCEDURES so data flow through them is followed. Reports RSLIN_SEC_DISPLAY_VULN_PROC and RSLIN_SEC_DISPLAY_BADIS show what is registered and which data sources count as secure.
  3. 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.
  4. 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 TRANSACTION on older releases, need an exemption to suppress the message.
  5. 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.
  6. Remediate the legacy backlog by exposure: RFC-enabled and HTTP-exposed code first, then reports with dynamic SQL on sensitive tables, then the rest.
  7. 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

FrameworkReferenceHow this guide applies it
NIST SP 800-53 Rev 5SA-11 Developer Testing and Evaluation; SA-15 Development Process, Standards, and ToolsCVA in ATC as a mandatory gate; documented exemption process
NIST SP 800-53 Rev 5SI-10 Information Input ValidationCL_ABAP_DYN_PRG, allow lists, logical file names
NIST SP 800-53 Rev 5AC-3 Access Enforcement; AC-6 Least PrivilegeExplicit AUTHORITY-CHECK, narrow RFC roles, UCON
NIST SP 800-53 Rev 5AU-2 Event Logging; CM-3 Configuration Change ControlSecurity Audit Log events; transport release gate
NIST CSF 2.0PR.PS-06 Secure software development practicesSecure coding rules and monitored checks across the ABAP lifecycle
ISO/IEC 27001:2022 Annex A8.28 Secure coding; 8.29 Security testing in development and acceptanceCoding rules above; ATC runs before transport
CWECWE-89, CWE-78, CWE-22, CWE-79, CWE-94, CWE-862, CWE-798SQL, OS command, path, XSS, code injection, missing authorisation, hard-coded credentials
MITRE ATT&CKT1190 Exploit Public-Facing ApplicationInjection 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-CHECK followed by code that ignores sy-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_TCODE that 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_NAM checks.
  • 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_RFC values. 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_quotes without the surrounding quotes, leaving injection open. Use quote for SQL literals and the built-in escape function 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-CHECK before the data access, with all non-zero sy-subrc values treated as denial.
  • CALL TRANSACTION uses WITH 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_PRG validation on every external value.
  • No FILTER addition on OPEN 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_method is 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

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.

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 14 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.