Skip to main content
SAP Pentest Playbook
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage
Edit page

Lateral Movement Through SAP Landscapes

Description

In many SAP landscapes, access to one SAP system can become a starting point for lateral movement into other systems. This is especially relevant when sandbox, development, or quality assurance systems have RFC connections to productive systems.

This attack path is commonly known as RFC hopping. It can occur when RFC Type 3 destinations in SM59 contain stored credentials, trusted relationships, or technical users with excessive authorizations in the target system.

SAP recommends not storing logon information for dialog users in RFC destinations. SAP also recommends that system users with stored logon data should have only a minimal level of rights in the target system.

Risk

RFC hopping can lead to unauthorized access to productive SAP systems and the data they contain.

Depending on the authorizations of the configured RFC user, an attacker may be able to:

  • log on directly to the remote system,
  • execute remote-enabled function modules,
  • read sensitive business or security-relevant tables,
  • extract password hashes or sensitive configuration data,
  • create or modify users,
  • assign roles or profiles,
  • escalate privileges in the target system,
  • use the compromised target system as a new pivot point for further lateral movement.

Attack Scenarios

Dialog user stored in an RFC destination

An RFC Type 3 destination in SM59 may contain a stored dialog user with excessive privileges in the target system.

If an attacker gains access to the source system and can access the destination, the Remote Logon function may allow direct interactive access to the configured target system.

This is especially critical when the source system has a lower security classification than the target system, for example:

  • sandbox to production,
  • development to production,
  • quality assurance to production.

Technical user with excessive RFC authorizations

An RFC Type 3 destination may also use a non-dialog or technical user. Even without interactive logon, this user can still be abused if it has excessive RFC authorizations.

For example, remote-enabled function modules may allow access to sensitive data or administrative actions in the target system. SAP documents that access to RFC function modules is controlled by authorization object S_RFC, including the fields RFC_TYPE, RFC_NAME, and activity 16 for execute.

A particularly sensitive example is RFC_READ_TABLE. SAP notes in the context of technical RFC users that RFC_READ_TABLE is not assigned to certain roles because it would allow the user to read almost all tables.

User creation or privilege escalation through RFC

If the RFC user has sufficient authorizations, remote-enabled user administration functions may be abused to create or modify users in the target system.

For example, an attacker may abuse BAPI_USER_CREATE to create a new SAP user in the remote system. In a second step, user administration BAPIs or function modules may be used to assign powerful roles or profiles, such as SAP_ALL.

This can result in an attacker-controlled user with extensive authorizations in the remote productive system.

Mitigation

RFC architecture and segmentation

  • Do not create RFC connections from systems with a lower security classification to systems with a higher security classification unless there is a documented business requirement.
  • Treat RFC connections from development, sandbox, or quality assurance systems to production as security boundary violations unless explicitly justified and controlled.
  • Avoid RFC paths such as development to production or quality assurance to production.
  • Where such connections are unavoidable, document the purpose, owner, source system, target system, user, required authorizations, and compensating controls.
  • Regularly review RFC destinations in SM59, especially destinations with stored credentials.

Stored credentials

  • Do not store credentials for dialog users in RFC destinations.
  • Avoid generic or shared users in RFC destinations.
  • Use dedicated technical users where stored credentials are required.
  • Restrict technical users to the minimum authorizations required for the specific business purpose.
  • Do not use SAP_ALL, SAP_NEW, broad S_RFC, or other excessive authorizations in RFC users.
  • Rotate passwords for stored technical users according to the organization’s credential policy.

RFC authorizations

  • Restrict S_RFC to the required function groups or function modules only.
  • Avoid wildcard authorizations such as broad access to all RFC function groups.
  • Review access to sensitive remote-enabled function modules, especially modules that can read tables, modify users, assign roles or profiles, execute commands, trigger jobs, or access security-relevant configuration.
  • Pay special attention to functions such as RFC_READ_TABLE, BAPI_USER_CREATE, and user administration-related BAPIs or function modules.
  • Explicitly review whether RFC users can create users, change users, assign roles, assign profiles, or indirectly grant authorizations such as SAP_ALL.

Trusted RFC

  • Review trusted RFC relationships separately.
  • Restrict and monitor authorizations related to trusted RFC, especially S_RFCACL.
  • Avoid trust relationships from lower-classified systems to higher-classified systems unless strictly required and risk-accepted.

Detection and Monitoring

Monitor for indicators such as:

  • remote logons from development, sandbox, or quality assurance systems to production,
  • execution of sensitive remote-enabled function modules,
  • unusual use of RFC_READ_TABLE,
  • execution of BAPI_USER_CREATE or similar user creation functions via RFC,
  • execution of BAPIs or function modules that assign roles or profiles to users,
  • creation of users through RFC connections,
  • assignment of critical roles or profiles such as SAP_ALL, SAP_NEW, or highly privileged custom roles,
  • user creation followed shortly by role or profile assignment,
  • user creation or privilege assignment performed by technical RFC users,
  • changes to RFC destinations in SM59,
  • changes to stored credentials,
  • trusted RFC logons,
  • failed or unusual RFC authorization checks.

Recommended SAP data sources include:

  • Security Audit Log,
  • system log,
  • change documents for user and role administration,
  • RFC destination change monitoring,
  • role and authorization reviews,
  • SIEM correlation for cross-system access patterns.

References