abap code qualität - best practices
TRANSCRIPT
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Dr. Markus Schumacher
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
SAP Security Forum, 15. Mai 2013, Lili Tempel / Offenbach
ABAP Code Qualität - Best Practices
Andreas Wiegenstein
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Andreas Wiegenstein
Gründer von Virtual Forge (Heidelberg), verantwortlich für Research &
Development
SAP Security Researcher, aktiv seit 2003
Hat aktuell die meisten Credits von SAP erhalten (49 gemeldete Schwachstellen)
Sprecher auf internationalen Konferenzen
SAP TechEd 2004 (USA & Europa) / 2005 (USA) / 2006 (USA), DSAG 2009
Black Hat 2011 (Europe), Hack in the Box 2011 (Europe)
Troopers 2011, 2012, 2013, RSA 2012 (USA), IT Defense 2013
Co-Autor von „Sichere ABAP Programmierung" (SAP Press)
Training Class WDESA3 @ SAP University
Mitwirkung am DSAG Best Practice Leitfaden Development (2013)
Mein Auto, mein Haus, mein Boot, …
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
CONTENTS
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Teil 1: Risiken
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Unternehmen haben ~ 1.65 Mio LOC Custom ABAP (netto) *
Dies entspricht etwa 1% des SAP Standards (ECC 6.0)
Das wären 8 Bermuda Dreiecke auf der Erde, was der doppelten
Fläche des Mittelmeeres entspräche.
* Virtual Forge Studie mit 45 Firmen und 100 Mio LOC (netto)
Netto = Code ohne Kommentare und Leerzeilen
Eigenentwicklungen in Zahlen
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
ABAP Code im IKS Kontext
IKS-Struktur im ERP-Umfeld
Generellen IT Kontrollen (ITGC - IT General Controls)
Änderungswesen (Change Management)
ABAP Code
Risiken für Geschäftsprozesse
Vollständigkeit Rechte Richtigkeit Nachvollziehbarkeit … Funktionstrennung Datenschutz
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Ein Unternehmen haftet immer für eigenen Code*
Relevanz
Hausinterne Entwicklung
Outsourcing
Firmenzukäufe
* (Chuprunov, SAP Revision, SAP Press, 2012)
SAP Audits
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Eigenentwicklungen
Funktionsbaustein ZFB1
INSERT REPORT
Eigenentwicklungen können sämtliche Regeln außer Kraft setzen
Business Server Page ZBSP
Web Dynpro Anwendung ZWD
Transaktion ZTRANS1
REPORT ZREP
Funktionsbaustein ZFB2 Transaktion ZTRANS2
Risiko
Risiko
Risiko
Risiko
Risiko
Risiko
Risiko Erzeugt ABAP Programme
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Risiko: ABAP Command Injection
Funktionale Analyse des Befehls INSERT REPORT
1. Auswirkungen auf die Authorization Trace
2. Auswirkungen auf einem Produktivsystem
3. Modifikation des SAP Standards
DEMO
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
BIZEC APP/11 Standard (Auszug)
9
APP-01 ABAP Command Injection Critical
Coding that dynamically creates and executes ABAP programs based on user input on a productive system, bypassing SE80 and the concept of a three-tier-system landscape.
Violates: PG-1, PG-2, PG-3, PG-4, PG-5, PG-6, PG-7
Exemplary SAP Note: 1589919
APP-02 OS Command Injection Critical
Coding that executes arbitrary (input-based) commands on the operating system, bypassing the allowed commands specified in SM49/SM69 and S_LOG_COM authorizations.
Violates: PG-6, PG-7
Exemplary SAP Note: 1520462
APP-03 Native SQL Injection Critical
Coding that executes arbitrary (input-based) native SQL commands on the SAP database, bypassing any Open SQL restriction.
Violates: PG-1, PG-2, PG-4, PG-6, PG-7
Exemplary SAP Note: 1456569
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Was ist der kürzeste Weg / Befehl
mittels ABAP Code
SAP_ALL Berechtigung
zu erhalten?
Quiz
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
56 Zeichen
UPDATE usrbf2 SET bname = sy-uname
WHERE bname = 'SAP*'.
Lösung
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
CONTENTS
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Teil 2: Lösungen
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
1. Erkenntnis 2. Akzeptanz 3. Die richtigen Dinge tun 4. Kontrollen
Sichere Programmierung als Prozess Herausforderungen und Tipps
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Der Anfang
Herausforderung #1
Die Vergangenheit bewältigen
Herausforderung #2
Die Zukunft besser gestalten
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
‘Get clean‘ Phase
Identifizieren & Entfernen von Dead Code (Quick Win)
Beseitigt üblicherweise etwa 30% aller Fehler *
Keine Programmierung erforderlich
Keine funktionalen Nachtests erforderlich
Identifizieren & Mitigieren der kritischsten Fehler
Fehler identifizieren und priorisieren
Quick-Wins identifizieren (z.B. Fehler die automatisch korrigiert werden können)
APIs und Mitigations-Strategien bereitstellen
Ein Mitigations-Team trainieren
Die kritischsten Fehler mitigieren
Funktionale Nachtests durchführen
Auf „Domino-Effekte“ achten
* Kunden mit großer Code-basis (> 1 Mio LoC)
#1 Die Vergangenheit bewältigen
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Nach dem ‘Aufräumen’
Herausforderung #1
Die Vergangenheit bewältigen
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
‘Stay clean‘ Phase
Verbesseren Sie Ihren Entwicklungsprozess
Erkennen Sie Ihre Risken
Erstellen Sie “vernünftige” Anforderungen
Befähigen Sie Ihre Entwickler
Trainieren Sie sie bzgl Sicherheit und Sicherheitsbewusstsein
Stellen Sie ihnen Leitfäden für die sichere Entwicklung zur Verfügung
Stellen Sie ihnen Testwerkzeuge zur Verfügung
Setzen Sie Ihre Richtlinien auch durch
Automatisieren Sie Ihre Qualitätssicherung
Informieren Sie das Management
Machen Sie Fortschritte sichtbar
#2 Die Zukunft besser gestalten
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
‘Stay-clean’ Phase
Challenge #2
Proving a better Future
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Resümee
Unternehmen haften für ihre Eigenentwicklungen
Eine Sicherheitsinitiative muss die Probleme der Vergangenheit
adressieren und vor allem neue Probleme verhindern
Wenn Sie ihren Sicherheitsprozess nicht durchsetzen können,
wird er nicht funktionieren
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
CONTENTS
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Teil 3: CodeProfiler
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
CodeProfiler Übersicht
Seit Jahren im produktiven Einsatz in der Industrie
200 Testfälle für Security, Compliance, Performance, Robustheit und Wartbarkeit
Individuelle Bewertung der Schwachstellen ermöglicht Priorisierung
Umfangreiche Fehlerbeschreibungen und Lösungsvorschläge
Hohe Akzeptanz bei Entwicklern durch Integration in SAP Entwicklungsumgebung
Revisionssichere Berichte
Hochperformantes System: >5 Milliarden Zeilen Code pro Woche bei einem Industriekunden
BI Dashboard für das Management
Innovatives Verfahren zum Aufdecken von Datenlecks: S-DLP
Vollständige Sicherheitskontrolle durch TMS Integration -> „Stay clean“
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
TMS Integration inkl. Workflow Automatische Kontrolle aller Transporte
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Datenlecks im Code
FUNCTION z_get_PA0002_data .
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(I_PERNR) LIKE PA0002-PERNR
*" VALUE(I_PERID) LIKE PA0002-PERID
*" EXPORTING
*" VALUE(E_ERRMSG) TYPE CHAR200
*" TABLES
*" ET_PA0002 STRUCTURE PA0002
...
INPUT
OUTPUT
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Datenlecks im Code (2)
FUNCTION z_get_PA0002_data .
...
SELECT * FROM pa0002 INTO lt_pa0002 WHERE PERNR = i_pernr.
" Plausibility check
IF lt_pa0002-perid <> i_perid.
CONCATENATE `PERNR and PERID don‘t match. PERNR ` i_pernr
` corresponds to PERID ` lt_pa0002-perid
`, not to PERID ` i_perid
INTO e_errmsg.
EXIT.
ENDIF.
Spalte perid in Tabelle pa0002 enthält die Social Security Number
Anwender kontrolliert die WHERE Bedingung (durch Input)
Die Funktion ist RFC-fähig
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Unsere Referenzen
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Virtual Forge CodeProfiler ... schützt Siemens
Quelle: Success Story mit Siemens, www.virtualforge.com
„Eine Kernanforderung bestand darin, jede Woche mehrere
Milliarden Zeilen Code zu scannen. Gemeinsam mit Virtual Forge
ist uns damit eine bisher einzigartige Lösung gelungen.“
Michael Brauer,
Leiter Abteilung Corporate Automation
Zentralstelle Corporate Information Technology der Siemens AG
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Quelle: Success Story mit SAP, www.virtualforge.com
„Durch den Einsatz von Virtual Forge CodeProfiler und die enge
Zusammenarbeit mit Virtual Forge konnten wir die Sicherheit im
Unternehmen verbessern und gleichzeitig die Qualität erhöhen.“
Ralph Salomon,
Vice President IT Security & Risk Office bei SAP
Virtual Forge CodeProfiler ... schützt SAP
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Quelle: Success Story mit Linde, www.virtualforge.com
„Seit wir das Tool einsetzen, sind die Entwickler achtsamer geworden
und liefern bessere Qualität.“
Stephan Sachs,
Manager für Applikationssicherheit bei Linde
Virtual Forge CodeProfiler ... schützt Linde
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Quelle: Success Story mit Mölnlycke, www.virtualforge.com
„Der Einsatz von Virtual Forge CodeProfiler hat unsere Arbeitsweise
revolutioniert – ohne signifikanten Aufwand oder Kosten."
Roderik Mooren,
IT Director bei Mölnlycke
Virtual Forge CodeProfiler ... schützt Mölnlycke
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
„Wir freuen uns, dass unser langjähriger Partner Virtual Forge ein
Tool für automatisierte Sicherheitstests zur Verfügung stellt.”
SAP
® Executive Board Member Gerhard Oswald (2009)
„Cool Vendor 2011”
Gartner benennt Virtual Forge zum „Cool Vendor 2011” im SAP EcoSystem
„CodeProfiler ist eine exzellente Lösung“
Expertenmeinungen Was andere über Virtual Forge sagen ...
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
ABAP Security Ressourcen
Literatur
Organizationen
Sichere ABAP-Programmierung (SAP PRESS, 372 S., 2009)
Andreas Wiegenstein, Markus Schumacher,
Sebastian Schinzel, Frederik Weidemann
BIZEC – Business Security Initiative
http://www.bizec.org
Links SAP Security Advisories von Virtual Forge
http://www.codeprofilers.com/index.php/advisories.html
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Take the Test!
Complimentary Scan
Virtual Forge
CodeProfiler
unter www.virtualforge.com
• Schwachstellen-Bericht
• Risiko-Priorisierung
• Beispiele von konkreten Schwachstellen
• Div. Code-Metriken
• Benchmark (auf Wunsch)
Robustheit & Wartbarkeit
Performance
Data Loss Prevention
Sicherheit & Compliance
Ihr
ABAP™-
Code
Getting Started Complimentary Scan
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Kontakt Informationen
VIRTUALFORGE GmbH
Web: http://virtualforge.com
Phone: + 49 (0) 6221 86 89 00
Twitter: @codeprofiler
© 2011 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
TITEL bearbeiten
© 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved. © 2013 Virtual Forge GmbH | www.virtualforge.com | All rights reserved.
Disclaimer
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 authors assume no responsibility for errors or omissions in this document. The authors do 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 authors 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.
© 2013 Virtual Forge GmbH.