Close

HAVE QUESTIONS?

A partner account manager can help. Contact us today.

Subscribe me to your mailing list

SAP Afaria Security: Stored XSS vulnerability – detailed review

Today we will talk about SAP Afaria Security. We will show how SAP Afaria, an MDM solution from a world-famous software vendor, works and how cybercriminals can attack it in different ways using Stored XSS vulnerability.

In a nutshell, MDM is a set of services that help an administrator of a large company to control the mobile devices (smartphones, tablets, phablets and so on and so forth) of employees, thus establishing the security measures of corporate data stored and processed on those devices. A special application called MDM client is installed on a device and allows administrators to implement settings.

Afaria is used by companies around the world. We have found about 140 Afaria servers available via the Internet.

SAP Afaria Security worldwide

As you can see from the graph, the largest number of Afaria services is implemented in the US and China.

We also have discovered several SAP Afaria vulnerabilities and would like to describe the most interesting of them.

SAP Afaria Security? Really? what about Stored XSS vulnerability?

The administrative part of SAP Afaria performs the basic functionality and is available via browser. Web administrative console is where a system administrator can view a list of all connected devices, create new mobile device configurations, download applications, control devices, etc.

So, the Stored XSS vulnerability in the administrative console is likely to be critical for the entire system and for the administrator in particular. A common Afaria user, of course, can’t obtain access to these functionalities. However, an injection of user data is still possible. So, let's examine what will happen if we try to connect a new device to the server without the proper rights (and the user account).

 connection to the server without rights and accounts

That’s what we get: the server, of course, does not allow us to connect this device. However, the list of devices in the administrative console (it is the administrator’s main workspace) shows the information about the device marked as “Not approved”. It means that an attacker can inject some data into the administrative console anonymously. Guess in which field a JS injection is possible. The server does not filter the information before displaying the device IMEI.

It looks like a typical stored XSS. However, the exploit seems interesting because the length of IMEI field is restricted by 15 characters. This restriction doesn’t allow one to inject malicious JavaScript code. But nothing prevents attackers from sending several connection requests specifying only a part of the JS payload and comments.

Let’s assume the attackers want to inject the following JS code:

To do so, they have to send a request to the server with the following values in the IMEI field:

As you may notice, there are special characters /**/ in every query. They are used to mark comments in JS. This way, unnecessary parts of HTML markup that prevent getting the final result are deleted.

What’s the final result? The web server will build an HTML page in the admin panel in which all the little pieces will be brought together into one JS script to be executed during the administrator’s session. It allows the attacker to gain data from the Afaria admin panel, and thus to control all devices connected to the server.

The screenshot below shows the administrative console’s source code with JS injected into the device IMEI field:

administrative console’s source code with injected JS

Stored XSS vulnerability: Wrap-up

The XSS vulnerability was closed by SAP. Install SAP Note 2152669 to fix this issue. To prevent this vulnerability as well as a plethora of other vulnerabilities in SAP, we recommend the following services: SAP Vulnerability Assessment, SAP Security Assessment, SAP Security Trainings, ABAP Code Security Review, SAP Penetration testing.

Please keep in mind that this issue is very critical because it can be remotely exploited without authentication, and there are at least 140 servers available on the Internet. An attacker can get complete control over all mobile devices of organization, such as remotely wipe data, lock all smartphones or even force to upload malicious backdoor which will control user’s data, send critical documents to C&C server, spy on employees, read messages, and record video from cameras.

We also recommend reading our whitepaper about XSS Vulnerabilities in SAP and how to prevent them in custom code.

Stay tuned for our new updates about SAP Afaria Security and more SAP security research.