Hack In The Box Conference 2011, Amsterdam. Dr. Markus Schumacher



Similar documents
Andreas Wiegenstein Dr. Markus Schumacher

Detecting Data Leaks in SAP -

SAP NetWeaver Application Server Add-On for Code Vulnerability Analysis

Auditing the Security of an SAP HANA Implementation

Inception of the SAP Platform's Brain Attacks on SAP Solution Manager

SAP NetWeaver Application Server Add-On for Code Vulnerability Analysis. Patrick Hildenbrand, Product Management Security, SAP AG September 2014

Mitigating Risks and Monitoring Activity for Database Security

Top 10 most interesting SAP vulnerabilities and attacks Alexander Polyakov

ATTACKS TO SAP WEB APPLICATIONS

Ensuring the Security and Quality of Custom SAP Applications

SAP Secure Operations Map. SAP Active Global Support Security Services May 2015

How to Configure Access Control for Exchange using PowerShell Cmdlets A Step-by-Step guide

An Oracle White Paper June Security and the Oracle Database Cloud Service

zur Erstellung von Präsentationen

AC 10.0 Centralized Emergency Access

Active Directory Change Notifier Quick Start Guide

SEC100 Secure Authentication and Data Transfer with SAP Single Sign-On. Public

Managing for the Long Term: Keys to Securing, Troubleshooting and Monitoring a Private Cloud

Oracle Whitepaper April Security and the Oracle Database Cloud Service

SAP Operational Process Intelligence Security Guide

Security Guide SAP GUI for Windows

How To Secure An Rsa Authentication Agent

PLSAP CONNECTOR FOR TALEND USER MANUAL

FINAL DoIT v.8 APPLICATION SECURITY PROCEDURE

ITM204 Post-Copy Automation for SAP NetWeaver Business Warehouse System Landscapes. October 2013

Reference Architecture: Enterprise Security For The Cloud

Monitoring and Management of Landscapes with SAP NetWeaver Administrator. Dieter Krieger, SAP AG

How To Manage Web Content Management System (Wcm)

TERMS AND CONDITIONS

SAP BW on HANA & HANA Smart Data Access Setup

ABAP How To on SQL Trace Analysis

SAP SECURITY CLEARING THE CONFUSION AND TAKING A HOLISTIC APPROACH

How To Configure MDM to Work with Oracle ASM-Based Products

Fulfilling HIPAA Compliance by Eliminating

Dell InTrust Preparing for Auditing Microsoft SQL Server

Oracle Corporation

OData in a Nutshell. August 2011 INTERNAL

The SAProuter An Internet Window to your SAP Platform (and beyond)

IBM Security Privileged Identity Manager helps prevent insider threats

SAP Project Portfolio Monitoring Rapid- Deployment Solution: Software Requirements

BM482E Introduction to Computer Security

CYBER-ATTACKS & SAP SYSTEMS Is our business-critical infrastructure exposed?

Secure Friendly Net Detection Server. July 2006

Getting Started with the License Administration Workbench 2.0 (LAW 2.0)

Dell One Identity Cloud Access Manager How to Configure for SSO to SAP NetWeaver using SAML 2.0

Unbreakable ABAP? Vulnerabilities in custom ABAP Code Markus Schumacher, Co-Founder Virtual Forge GmbH

Developing Applications for Integration between PI and SAP ERP in Different Network Domains or Landscapes

Master Data Governance Security Guide

SAP GRC Access Control: Background jobs for risk analysis and remediation (formerly Virsa Compliance Calibrator)

Implementing Outlook Integration for SAP Business One

Compliance & SAP Security. Secure SAP applications based on state-of-the-art user & system concepts. Driving value with IT

SQL Injection January 23, 2013

Streamlining Web and Security

EAS-SEC Project: Securing Enterprise Business Applications

Business-Driven, Compliant Identity Management

Password Management. Password Management Guide HMS 9700

Backup & Restore with SAP BPC (MS SQL 2005)

Symantec Mobile Management for Configuration Manager

How to Implement the X.509 Certificate Based Single Sign-On Solution with SAP Netweaver Single Sign-On

BC450 ABAP Performance: Analysis and Optimization

CUSTOMER Presentation of SAP Predictive Analytics

Enabling Full-Text Search for Business Objects in mysap ERP

Hardening of SAP HTTP- and Webservices

Secure Configuration Guide

Making Database Security an IT Security Priority

Using SAP Logon Tickets for Single Sign on to Microsoft based web applications

Introduction to SAP HANA SQLScript Rich Heilman SESSION CODE: BT162

Object Level Authentication

S E C U R I T Y A S S E S S M E N T : B o m g a r B o x T M. Bomgar. Product Penetration Test. September 2010

TERMS AND CONDITIONS

EC-Council CAST CENTER FOR ADVANCED SECURITY TRAINING. CAST 619 Advanced SQLi Attacks and Countermeasures. Make The Difference CAST.

IGEL Universal Management. Installation Guide

RSA SecurID Software Token Security Best Practices Guide

Set Up Hortonworks Hadoop with SQL Anywhere

SAP Business Intelligence Suite Patch 10.x Update Guide

THE STATE OF SAP SECURITY 2013: VULNERABILITIES, THREATS AND TRENDS

Web site Terms and Conditions

SAP Mobile Documents. December, 2015

CHANNEL PARTNER (VAR) Technical Support Network. SAP Global Service & Support March 2011

Securing Data on Microsoft SQL Server 2012

E-Recruiting Job Board Integration using XI

3 rd InfoCom Security, Athens, 10 Arpil 2013

SQL Injection 2.0: Bigger, Badder, Faster and More Dangerous Than Ever. Dana Tamir, Product Marketing Manager, Imperva

Mobile app for Android Version 1.0.x, January 2014

PCI DSS Best Practices with Snare Enterprise Agents PCI DSS Best Practices with Snare Enterprise Agents

Integrating Dell server hardware alerts into SBS 2008 report. By Perumal Raja Dell Enterprise Product Group

Processed on SAP Solution Manager Service Center Release EHP 1 for Solution Manager 7.0 Telephone Service Tool 701_2011_1 SP0 Fax

8 Steps to Holistic Database Security

SAP NetWeaver Identity Management Identity Services Configuration Guide

Data Transfer Tips and Techniques

SAP Security Monitoring with agilesi. agilesi tm Solution Brief Product Specification July 2012 Version 1.1

EMC Documentum Content Services for SAP iviews for Related Content

Ariba Network Integration to SAP ECC

MySQL Security: Best Practices

SAP Business One mobile app for Android Version 1.0.x November 2013

ChangeAuditor 6.0 For Windows File Servers. Event Reference Guide

Hardening of SAP HTTP- and Webservices

Transcription:

Hack In The Box Conference 2011, Amsterdam Dr. Markus Schumacher PPT SQL Masterfolie Injection with ABAP zur Ascending Erstellung from Open von SQL Injection Präsentationen to ADBC Injection

Who am I Andreas PPT Masterfolie Wiegenstein CTO and founder of Virtual Forge, responsible for R&D SAP Security Researcher, active since 2003 Speaker at SAP TechEd 2004, 2005, 2006, DSAG 2009, BlackHat 2011 Co-Author of "Secure ABAP Programming" (SAP Press) Virtual Forge GmbH SAP security product company based in Heidelberg, Germany Focus on (ABAP) application security services ABAP Security Scanner ABAP Security Guidelines ABAP Security Trainings SAP Security Consulting

Belief: "Our SAP system is secure." PPT Roles Masterfolie & Authorizations Segregation of Duties Secure Configuration & System / Service Hardening Encryption Secure Network Infrastructure Password Policies Patch Management Identity Management Single Sign-on

Reality-Check PPT Masterfolie

Inhalt PPT Masterfolie 1. zur About Erstellung ABAP von Präsentationen 2. SQL Injection revisited 3. Open SQL (OSQL) Overview, Risks & Mitigations 4. Native SQL 5. ABAP Database Connectivity (ADBC)

1. PPT and Masterfolie then there was ABAP

Advanced Business Application Programming PPT Proprietary Masterfolie language, exact specification not (freely) available zur Platform-independent Erstellung von code Präsentationen Client separation built-in * Integrated auditing capabilities System-to-System calls via SAP Remote Function Call (RFC) Client-Server communication via SAP GUI (DIAG protocol) Various programming paradigms: Programs & Forms, Reports, Function Modules, Dynpros Classes & Methods, Business Server Pages, Web Dynpro ABAP Integrated platform-independent SQL Standard: Open SQL Built-in authentication, roles and (explicit) authorization model Thousands of well-known standard programs and database tables 150+ Million Lines of Code in an ECC6.0 System

A closer look at Client Separation PPT Masterfolie Client Separation Client 007 Client 023 Client 042 2010 Virtual Forge GmbH. All rights reserved. Users log on to "clients" Clients represent business (and user) data of independent organizations The SAP system implicitly separates client data in the database Done via a special column that indicates, if a table is client-dependent ABAP code is client-independent. Every program is available on all clients

Attack Surface of ABAP PPT Masterfolie

2. PPT SQL Masterfolie Injection revisited

SQL Injection Overview PPT Special Masterfolie form of In-band Signalling 1) Data (input) is combined with commands (SQL syntax) 2) Result (data + commands) is executed 3) Commands embedded in data can corrupt the intended SQL commands Typical test patterns ' or 1=1 -- ' or 1=1 /* Countermeasure: Prepared Statements SQL Injections are known at least since 12/1998 (Phrack.org issue #54)

SAP-specific SQL Injection Risks PPT Illegal Masterfolie access to data in other clients zur Modification Erstellung of user von accounts Präsentationen and user authorizations (SOX violation) E.g. Assign unauthorized user SAP_ALL privileges Undocumented changes to critical database tables (SOX violation) No records in CDHDR, CDPOS, Read access to HR data (Privacy issue) E.g. social security number (PA0002-PERID) Access to credit card data (PCI/DSS violation) E.g. BSEGC-CCNUM Access to bank accounts of customers and suppliers E.g. customer bank account data (KNBK-BANKN) Manipulation of financial data (SOX violation) E.g. tampering with BSEG

3. PPT Open Masterfolie SQL (OSQL) Overview, Risks & Mitigations

Open SQL Overview PPT Open Masterfolie SQL commands are integrated in the ABAP language zur Erstellung SELECT, UPDATE, von INSERT, Präsentationen DELETE, MODIFY OSQL commands are compiled together with the ABAP program Most ABAP Code (>95%) uses Open SQL for DB queries Open SQL automatically enforces SAP security features Only defined database commands can be executed Client separation Logging

Open SQL Example #1 Simple OSQL query (SELECT) REPORT PPT SQL_01. Masterfolie DATA lt_sec TYPE sbook. PARAMETERS p_carrid TYPE string. SELECT class passname fldate FROM sbook CLIENT SPECIFIED INTO CORRESPONDING FIELDS OF lt_sec WHERE carrid = p_carrid AND reserved = ' '. WRITE : / lt_sec-class, lt_sec-passname, lt_sec-fldate. ENDSELECT.

Open SQL Example #2 OSQL query with dynamic WHERE condition REPORT PPT SQL_02. Masterfolie PARAMETERS p_carrid TYPE string. DATA lt_sec TYPE sbook. DATA lv_where TYPE string. CONCATENATE `carrid = '` p_carrid `' AND reserved = ' '` INTO lv_where. SELECT class passname fldate FROM sbook CLIENT SPECIFIED INTO CORRESPONDING FIELDS OF lt_sec WHERE (lv_where). WRITE : / lt_sec-class, lt_sec-passname, lt_sec-fldate. ENDSELECT.

Open SQL Example #3 OSQL query with dynamic table access REPORT PPT SQL_03. Masterfolie PARAMETERS p_table TYPE string. DATA lt_sec TYPE sbook. DATA lv_table TYPE string. CONCATENATE `S` p_table INTO lv_table. SELECT * FROM (lv_table) CLIENT SPECIFIED INTO CORRESPONDING FIELDS OF lt_sec. WRITE : / lt_sec-class, lt_sec-passname, lt_sec-fldate. ENDSELECT.

OSQL Injection Demos PPT Masterfolie DEMO

SAP Mitigation(s) PPT SAP Masterfolie Note 1520356 - Avoiding SQL Injections (https://service.sap.com/sap/support/notes/1520356) ABAP countermeasures available since 12/2010

SAP Mitigation(s) a closer look PPT Masterfolie zur DATA Erstellung str TYPE string. von Präsentationen ABAP strings are usually enclosed in ` (back ticks) str = `Hello string`. ABAP char arrays are usually enclosed in ' (single quotation marks) DATA chr TYPE c LENGTH 80. chr = 'Hello char'. Hence ` as well as ' can be used in dynamic OSQL to enclose variables CONCATENATE `carrid = '` p_carrid `' AND reserved = ' '` INTO str. CONCATENATE 'carrid = `' p_carrid '` AND reserved = ` `' INTO chr. SAP countermeasures include two methods to escape quotes cl_abap_dyn_prg=>escape_quotes_str(str) ` -> `` cl_abap_dyn_prg=>escape_quotes(chr) ' -> ''

SAP Mitigation(s) have Risks PPT Masterfolie zur cl_abap_dyn_prg=>escape_quotes_str Erstellung von Präsentationen The method-names suggest usage for a given variable type -> to use for strings cl_abap_dyn_prg=>escape_quotes -> to use for non-strings (character arrays) Careful: It's not the variable-type that's relevant but the type of quote used! Risk: The method-names are misleading and may confuse developers DATA lv_where TYPE string. P_carrid = cl_abap_dyn_prg=>escape_quotes_str( p_carrid ). CONCATENATE `carrid = '` p_carrid `' AND reserved = ' '` INTO lv_where.

SAP Mitigation(s) recommendation PPT Avoid Masterfolie zur cl_abap_dyn_prg=>escape_quotes_str Erstellung von Präsentationen Use cl_abap_dyn_prg=>escape_quotes cl_abap_dyn_prg=>quote_str cl_abap_dyn_prg=>quote These functions not only escape the input, but also wrap it in the same quote character they escape DATA lv_where TYPE string. P_carrid = cl_abap_dyn_prg=>quote_str( p_carrid ). CONCATENATE `carrid = ` p_carrid ` AND reserved = ' '` INTO lv_where. Examples cl_abap_dyn_prg=>quote_str( ) O`Neill -> `O``Neill` cl_abap_dyn_prg=>quote( ) O'Neill -> 'O''Neill'

4. PPT Native Masterfolie SQL

Native SQL Overview PPT Masterfolie "Native SQL" is SQL placed inside specific ABAP commands EXEC SQL ENDEXEC. Used when database-specific commands have to be executed that are not part of Open SQL Native SQL is always hard-coded Input is passed to placeholders (as in prepared statements) Native SQL bypasses SAP security features of Open SQL Client separation Restrictive access to SQL commands Native SQL can't access certain SAP tables Cluster Tables and Pool Tables don't physically exists in the DB No SQL Injection possible, but should not be used anyway

Native SQL Example Command EXEC SQL REPORT PPT SQL_04. Masterfolie DATA: f1 TYPE s_class. DATA: f2 TYPE s_passname. DATA: f3 TYPE s_date. PARAMETERS p_carrid TYPE string. EXEC SQL. SELECT CLASS, PASSNAME, FLDATE INTO :F1, :F2, :F3 FROM SBOOK WHERE CARRID = :p_carrid AND RESERVED = ' ' ENDEXEC. WRITE: / f1, f2, f3.

5. PPT ABAP Masterfolie Database Connectivity (ADBC)

ADBC Overview PPT Masterfolie ADBC allows to dynamically execute arbitrary SQL commands ADBC is technically based on SAP kernel calls CALL 'C_DB_EXECUTE' CALL 'C_DB_FUNCTION' ADBC is provided in ABAP classes CL_SQL_* and a function module CL_SQL_STATEMENT CL_SQL_PREPARED_STATEMENT DB_EXECUTE_SQL (Function Module) ADBC bypasses SAP security features provided by Open SQL Client separation Restrictive access to SQL commands Precompiled SQL statements Like Native SQL, ADBC can't access certain SAP tables

ADBC via CALL 'C_DB_EXECUTE' REPORT PPT SQL_05. Masterfolie DATA: lv_len TYPE i. DATA: lv_sqlerr TYPE i. PARAMETERS lv_stmt TYPE c LENGTH 80. lv_len = STRLEN( lv_stmt ). CALL 'C_DB_EXECUTE' ID 'STATLEN' FIELD lv_len ID 'STATTXT' FIELD lv_stmt ID 'SQLERR' FIELD lv_sqlerr. Executes an arbitrary SQL command (except SELECT) Used in function module DB_EXECUTE_SQL

ADBC via CALL 'C_DB_FUNCTION' REPORT PPT SQL_06. Masterfolie PARAMETERS lv_stmt TYPE c LENGTH 80. CALL 'C_DB_FUNCTION' ID 'FUNCTION' FIELD 'DB_SQL' ID 'FCODE' FIELD 'PO' ID 'STMT_STR' FIELD lv_stmt... Executes an arbitrary SQL command Used in class CL_SQL_STATEMENT

ADBC Injection Demos PPT Masterfolie DEMO

Related SAP Security Note PPT Masterfolie SAP Note 1456569 "Potential modification of persisted data" (https://service.sap.com/sap/support/notes/1456569) Virtual Forge Security Advisory SAP-NSI-01

Summary PPT Masterfolie Despite common belief, OSQL Injections are possible in ABAP Despite common belief, arbitrary SQL statements can be executed on SAP systems, using ADBC The criticality of an OSQL Injection depends on the affected table and whether it is read or write access. A single ADBC Injection means complete compromise of the SAP system

SAP / ABAP Security Information PPT Organizations Masterfolie BIZEC Business Security Initiative http://www.bizec.org Literature "Secure ABAP-Programming" (Learn German first ;-) SAP Press 2009 If you find new zero days secure@sap.com

Questions? PPT Masterfolie For the most current version of this document, visit http://www.virtualforge.com/ Andreas(dot)Wiegenstein(at)virtualforge(dot)com VirtualForge GmbH Speyerer Straße 6 69115 Heidelberg Deutschland Phone: + 49 (0) 6221 86 89 0-0 Fax: + 49 (0) 6221 86 89 0-101

Disclaimer PPT Masterfolie SAP, R/3, ABAP, SAP GUI, SAP NetWeaver and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. The author assumes no responsibility for errors or omissions in this document. The author does not warrant the accuracy or completeness of the information, text, graphics, links, or other items contained within this material. This document is provided without a warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. The author shall have no liability for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of this document. No part of this document may be reproduced without the prior written permission of Virtual Forge GmbH. 2011 Virtual Forge GmbH.