Monday, December 23, 2013

SAP Portal Security, lesson 1: Hacking KM

Dear readers!

In upcoming posts about SAP Portal Security I am planning to cover common mistakes done by IT departments during exposure of SAP Portals to the world wide web. We will start with the most basic ones, and dive in to the more complicated ones, but I will try to keep it as simple as it gets.

I suggest reviewing my previous post about exposing SAP NetWeaver to the world, if you are not yet exposing your SAP Portals to the internet.

Intro

SAP portal is used in many companies as a central access point to other SAP and non-SAP applications. There are plenty of reasons to do that, such Single Sign On (SSO), ease of access, user-friendly interface and many others. SAP portals, exposed to the internet, become an attractive target for hackers and enthusiasts like myself. Potential information stored in this SAP module can be used for business intelligence by competitors, which can steal information or affect the company's image by sabotaging the system.


Architecture

Let's take a look at SAP Portal architecture. It is important to know the elements of our system, how they interact, and how they can be hacked with a bit of knowledge. Here is a basic schema from SAP documentation:

The platform behind our SAP Portal is J2EE, which operates java applications, iViews, web services, servlets, and supports many standard protocols, such as WebDAV and others. From the scheme above you can see that SAP Portal is connected to back end modules, such as ERP, CRM, BW, LDAP and SQL server. The system can be installed on Microsoft / UNIX operating systems and have different SQL servers connected through JDBC, and it is important for our future sessions.

Finding exposed SAP portals


There is a mistaken opinion that SAP portals are rarely exposed to the World Wide Web, and they are heavily secured. You can search for the following expression to see how many there are:


Lesson 1: Knowledge Management 

I would like to start our vulnerabilities discovery with the most basic portal module - Knowledge Management (KM). This module is not actively changed by SAP for many years now, and it delivers many low-level protocols and features that are rarely secured. It can become a critical access point to the system, providing access to file repositories and system storage.

Here is a basic architecture overview of portal KM from SAP documentation:

As you can see from the overview, there is WebDAV through HTTP/S. Developers or hackers with a bit on scripting can perform Denial Of Service (DOS) attacks and overload the system storage, or steal information by accessing the module even with Guest authorization.

Let's give it a try. You will be surprised how many companies are not blocking access to their KM module, thus exposing their repositories to the internet without even knowing it. Try adding /irj/go/km/docs to the portal URL you have found before, and you will be able to navigate to the KM module. Here is a live example I found:


Some companies might be holding sensitive information on their KM repositories, without really managing authorizations and access points. This mistake is very common, and I believe it is the most amateur one.

But hey, we have another great feature that is not managed properly, it's called WebDAV protocol. It's widely-used protocol for reading / writing documents on web servers, and it appears to be wrongly treated in many organizations. 

For example, you can connect many web-facing KM repositories as network drives on your PCs, simple as that:



After doing that, injecting files to remote servers becomes a copy-paste task. What's even worse - in many cases you can delete content through WebDAV, which can sabotage the company.

Tips to keep it secure

1. Use SAP WebDispatcher (or other reverse proxy) to control accessible URLs by URL filtering
2. Do not connect your server file system as KM repository
3. Maintain KM permissions properly
4. Restrict WebDAV access to sensitive folders

Next time we will dive deeper, exploring servlets and security mechanisms in SAP portal, which allow creating users, assigning them to Administrators group, and performing OS-level commands.

Stay tuned! :-)

Wednesday, May 29, 2013

How to hack your SAP environment

Greetings, dear readers!

Today I would like to share with you some thoughts about security +SAP environment. I hear people talking about security a lot, discussing GRC implementations, HTTPS protocols appliances, and other security enhancements that are targeted to improve overall security and authorizations. We all love talking about cloud solutions, mobile tools and their security, and other aspects of everyday +SAP maintenance.

How about taking it to the previous level? The steps below can be executed by any user that has SAP GUI installation, and he doesn't even require a user in SAP. Be careful with your commands...

* This post applies to Windows-based installations, with SAP BASIS component lower than EHP1, patch 10.

  1. Open your SAP GUI
  2. Double-click on one of your SAP installations (I suggest you don't touch your production environment)
  3. Log on to the system, by changing client number to 066, user EARLYWATCH, password 'support'

  4. Execute transaction SM51
  5. While in SM51, execute the command GREP

  6. Paste the line below and click "Find" - you will get full configuration of the server



    As you might understand, you can execute command prompt commands directly from SAP, without even having a user there. You can, for example, change the word 'set' in the line above to 'ipconfig', which will return you the network configuration.

    Security, huh?

Saturday, April 6, 2013

Portal On Device in 10 minutes

Intro

In our modern world, era of BYOD (Bring Your Own Device) and other weird idioms, all SAP-running companies struggle to adjust to technology changes and developments. A couple of years ago IT support would have one answer to all users - "We support only Internet Explorer". Today, the world, where users choose their own way of working and their own device, IT have no choice - the have to support Chrome, Safari, Firefox - all those that were non-SAP browsers, running on top of Macs and mobile devices, and not only Microsoft operating systems.

Let's see how SAP portal supports all this heterogeneous environment, and allows us accessing it from a mobile device. In most cases, customers have a very similar requirement - to fit a small part of portal content to mobile devices, and hide all that heavy desktop-oriented content from mobile consumers.

The approach that we will use is Portal On Device with content filtering - let's start!

Preparation

First of all, you portal version should be at least 7.30.8, or 7.31.5.

In order to see the right content on your tablet / smartphone, perform following steps in NWA:

  1. Under Java System Properties, find a service called "Portal Runtime Container Extension" and set "html5.compliant" property to "iViewDependent"

  2. Under Application Modules, find a module called "com.sap.portal.navigation.helperservice", select it's web module "navigation_events_helper", and set property "FilterbyDesktopView" to 2. Set the property "FilterByExcludedFilterIDs" to be "com.sap.portal.doNotFilter".

    All content marked with this value will not be affected by filtering mechanism.

    You can find more information about filtering entry points here



    * Restart the portal instance
  3. Go to System Administration -> System Configuration -> Portal Display -> Desktops & Display rules, and copy-paste the following SAP standard folder with tablet desktop to you custom location:

  4. Open the copied portal desktop, and add a framework page to it (by default there is no page assigned)
  5. In the same place, set the following filter ID to this desktop: "com.sap.portal.tablet". Later on, you will add this filter ID to content that you wish to expose to mobile devices.
  6. Go to System Administration -> System Configuration -> Portal Display -> Desktop & Display Rules, open main rules collection and create a new rule:



    Now you are ready to prepare some mobile-oriented roles and expose them to end users!

Set the desired content

  1. Open your current desktop in use, and add following filter ID, which will allow existing non-filtered content to remain in place: com.sap.portal.emptyFilterID
  2. Copy-paste the standard tablet role from this location:


    The role will have standard filter ID maintained, so tablet content will not be shown to desktop users.
  3. Assign the created role to relevant users through User Management
  4. Please note that this role will be filtered by portal desktop settings made during our preparation. Although you assign yourself this role, you will be able to see it's content only on your mobile device. 

    In case you receive the following screen, please make sure that you are assigned with a mobile role, and filters you added to portal desktop are not blocking the content.

Once the configuration is done, you will be rewarded with this one:


Full POD guide can be found here.

Next time we will talk about launcher & content modifications and branding applications.

Good luck!

Wednesday, March 13, 2013

ESS / MSS Customization in EHP5

Intro

As you all might already heard, SAP is going ABAP all the way, meaning Employee Self Services (ESS) are all ABAP-based, since ECC EHP5 release. Manager Self-Services remain to be ABAP+Java, at least in EHP5 version. Although customization of ESS is done on ECC side, there is a common tradition to ask your portal consultant to do that. So, if you are either an HR consultant that wants to learn the subject, or a portal one-man-show consultant, this guide will help you start!


Pre-requisites

First of all, you can find the official ESS business package documentation here, or if you are into MSS as well - you can find it here. Let's start with the requirements:

  1. Enable IGS on your ECC server, according to note 1527176
  2. Make sure you have the required ESS & MSS business content deployed & enabled on ECC 
  3. On portal side, create EHP5 system in System Landscape. Please make sure you add a system alias "SAP_ECC_HumanResources". Now test the connection. Following tests must succeed:

    Add following system aliases:
    * SAP_ECC_Common*
    * SAP_EREC_TalentManagement
    SAP_ECC_HumanResources
  4. Download following portal business content from service marketplace, and upload it to portal through JSPM / developer studio:

    * BPERPESSWDA05 – according to note 1450179
    * BPERP5MSS05 (BP ERP05 MSS 1.51)
    * BPERPCOM05 -  COMMON PARTS
    * SAP MSS 630 – MSS WD for Java applications
    * PCUI_GP 633 -  component pre-requisite WD for Java applications

    The content you downloaded for deployment will consist of the following:
  5. Download following WebDynpro Java components for MSS from service marketplace (only if you plan to use the MSS):



    * PCUI_GP
    * MSS
    * SAP_PSS (if you use project management)
  6. Create required RFCconnections in WebDynpro content administrator
  7. Assign yourself the roles provided in business content:ESS: com.sap.pct.erp.ess.wda.Employee_Self_Service_WDA
    MSS: com.sap.pct.erp.mss.manager_self_service

Launchpad Customization

Launchpad is the first screen users land on when accessing the ESS. Please follow these steps in ECC:

  1. Run LPD_CUST and select ESS MENU
  2. Copy the launchpad to ZESS
  3. Remove unrelated applications (delete or move to inactive folder)
  4. You can add your portal custom applications starting with /irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2f...
  5. Change the role of launchpad to ZESS, which was created in step 2:
  6. Save and exit

ESS Customization

Here you will see example of personal info page customization.
  1. Go to SE80 and open package PAOC_ESS_PER_WDA
  2. Drill down to application configuration, and click "Start Configurator"

  3. Click "Go to component configuration" and click "Start Deep Copy
  4. Create a new package, and a new transport request, and then click "Ok"
    You will end up with a new configuration:

  5. Once your custom deep-copy component configuration is created, use Shift+F8 in order to launch the UIBB (building blocks) customization
  6. Once customized, go to LPD_CUST and set your new application configuration instead of the standard one
You can refer to SAP documentation in order to find the component package & name which you would like to customize.

* MSS Customization is still performed in the old Java-way, by launching relevant applications in Preview mode from portal Content Admin, and then Ctrl + Right click.

If you are interested in further development & support, please contact me directly.

Good luck!


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

Monday, January 14, 2013

Portal task management unleashed

Intro

During my final project for B.Sc. I did in Holon Institute of Technology, I had to do a research. There were many topics to pick from, but somehow I ended up doing a research about short-term tasks management in  matrix-based organizations. 

The issue came up from my everyday work at customer sites: my ongoing work was managed with Excel. I will skip the part about Excel disadvantages, as you all know them better then I do. Anyhow, we had to study available task management tools, learn their functionality, and propose a best-fit solution for ongoing task management. 

We finished the study, proposed a solution, got a good grade, and none of proposed tools was implemented, mostly because it requires more than just a research: a budget, top management support, training and so on...

And then I thought, why not implementing standard portal UWL workflow, and complete it with a functional management report to achieve the desired result?

Keep it standard

UWL is a good tool for portal users to process tasks from SAP back end systems, as it is flexible enough, thanks to XML configuration. You can make tasks look different, process them in different way, add fields from back end and even develop providers from third party systems.

There is also a built-in workflow engine, which requires no configuration - you can start managing tasks based on portal workflow, and have several nice features there:
  • Email notifications & reminders
  • Due date management
  • Group tasks creation
  • Task forwarding and ad-hoc tasks creation
  • Attachments
  • Tasks approval upon completion
  • Sequential tasks processing
The problem arises when you want to change the standard tasks creation screen, which looks like this:


There is no standard way to add a field here. And this is a huge problem for any customer, that wants to add subsidiary, company selection, or any other field. 

Of course we can take the source code, import it to NWDI, and start developing a new screen, but at this stage I decided to avoid such changes, for the sake of future SAP support and upgrades.

So, let's see what are we missing, and how we can extend this UWL to be a good task management solution...

Missing functionality

Additional fields
As mentioned before, there is no standard way to add fields to task creation screen, which makes UWL tasks information incomplete

Management report
Once managers are required to go over open tasks of their employees, they see only those tasks they are assigned to as trackers, or those they created themselves. You cannot expect employees to remember adding managers as trackers to all their tasks, which results in lack of control and transparency

Grouping of tasks
Issue is derived from missing option of adding fields: there is no way to assign task to some field and filter by this filed later on

Sending follow-ups
Standard workflow mechanism sends one follow-up email upon task overdue, but there is no way to initiate this process on demand

Due date monitoring
If users change due dates (and yes, task processors can do that) there is no central way to see all those tasks and check initial due date

Export to excel / PDF
Managers plan to take task list with them to some meeting, and there is no convenient way to export task list to excel and print it out

Statistics
There is no graphical tools to monitor tasks processing trends, such as tasks overdue time, task completion time and so on

A solution

In order to complete UWL task management with missing functionality, we can develop a report based on standard UWL tables. This approach keeps the tables structure and logic implemented in UWL, keeping our options of portal upgrade and maintenance open for the future:

  • Additional fields: can be held in an SQL table, mapped to standard task by task ID
  • Management report: can embed tailor-made logic with fields assignment, calculations and styling
  • Grouping of tasks: can be made by creating UME groups in the portal itself, and then select tasks of employees assigned to UME groups
  • Due date monitoring: we can load initial and current due dates and point out those that were changed
  • Export to excel: we can do any export we like, making this truly important function available
  • Statistics: we can use WebDynpro built-in graphic elements to provide analytic tools

Tables to use

There are several standard tables in the portal SQL database that should be used in order to build the functionality described above, and here they are:
  • Our own table for additional attributes
  • KMC_WF_WORKITEM - this table contains information about completion date (TIME_COMPLETED) and initial due date (DUE_DATE)
  • KMC_WF_WFTASK_USR - this table contains task assignees
  • KMC_WF_WFTASK - this is the table that contains tasks information

    Important note: don't use KMC_UWL_ITEMS2, this table holds cached tasks, and if you clear the cache all tasks will be missing from your report, until users access their UWL again.

Summary

The WebDynpro for Java application described above extends UWL to provide a good, user-friendly, full-cycle task management solution, with comprehensive functionality. Development of such a tool is a question of several days, and it's true value for any enterprise that have SAP portal.

You are welcome to download the solution for free.
Feel free to contact me directly.

Good luck!