[ERPSCAN-18-004] RCE via path Traversal using CSRF in SAP CRM

Application: SAP NetWeaver
Versions Affected: SAP CRM 13676083
Vendor URL: SAP
Bugs: CSRF, Path Traversal
Reported: 05.10.2017
Vendor response: 06.10.2017
Date of Public Advisory: 13.02.2018
Reference: SAP Security Note 2547431
Author: Vahagn Vardanyan (ERPScan), Vladimir Egorov (ERPScan)

VULNERABILITY INFORMATION

Class: Directory Traversal
Risk: Medium
Impact: Attacker could read content of arbitrary files on the remote server and expose sensitive data confidentiality
Remotely Exploitable: Yes
Locally Exploitable: Yes

CVSS Information

CVSS v3 Base Score: 6.6 / 10
CVSS Base v3 Base Vector:

AV: Attack Vector (Related exploit range) Network (N)
AC: Attack Complexity (Required attack complexity) Low (L)
PR: Privileges Required (Level of privileges needed to exploit) High (H)
UI: User Interaction (Required user participation) None (N)
S: Scope (Change in scope due to impact caused to components beyond the vulnerable component) Changed (C)
C: Impact to Confidentiality Low (L)
I: Impact to Integrity Low (L)
A: Impact to AvailabilityLow (L)

DESCRIPTION

An attacker can change the path and extension of the log file in SAP CRM using path Traversal and CSRF vulnerability, write the special Java code in this log file, and execute any command via HTTP request.

BUSINESS RISK

An attacker can use a Cross-Site Request Forgery vulnerability for exploiting an authenticated user’s session by making a request containing a certain URL and specific parameters. A function will be executed with an authenticated user’s rights. An attacker may use a Cross-Site Scripting vulnerability to achieve this or can present a specially crafted link to an attacked user.

VULNERABLE PACKAGES

CRM JAVA APPLICATIONS 7.01 SP009
CRM JAVA APPLICATIONS 7.02 SP004
CRM JAVA APPLICATIONS 7.30 SP012
CRM JAVA APPLICATIONS 7.31 SP009
CRM JAVA APPLICATIONS 7.32 SP004
CRM JAVA APPLICATIONS 7.33 SP000
CRM JAVA APPLICATIONS 7.54 SP001
CRM JAVA COMPONENTS 7.01 SP009
CRM JAVA COMPONENTS 7.02 SP004
CRM JAVA COMPONENTS 7.30 SP012
CRM JAVA COMPONENTS 7.31 SP009
CRM JAVA COMPONENTS 7.32 SP004
CRM JAVA COMPONENTS 7.33 SP000
CRM JAVA COMPONENTS 7.54 SP001
CRM JAVA WEB COMPONENTS 7.01 SP009
CRM JAVA WEB COMPONENTS 7.02 SP004
CRM JAVA WEB COMPONENTS 7.30 SP012
CRM JAVA WEB COMPONENTS 7.31 SP009
CRM JAVA WEB COMPONENTS 7.32 SP004
CRM JAVA WEB COMPONENTS 7.33 SP000

SOLUTIONS AND WORKAROUNDS

To correct this vulnerability, install SAP Security Note 2547431

TECHNICAL DESCRIPTION

Proof of Concept

Path Traversal

Using this path traversal an attacker can change CRM log path.

There is an authorization mechanism here, but there is no CSRF token (in configuration panel we enabled CSRF protection).

Uploading RCE

After creating an evil log file, an attacker can send this request with jsp shell to server, and server writes C:\usr\sap\DM0\J00\j2ee\cluster\apps\sap.com\com.sap.engine.docs.examples\servlet_jsp\_default\root\shell.jsp file this jsp code

Executing RCE