11.07.2015 Views

SAP Portal Hacking and Forensics at Confidence 2013 - ERPScan

SAP Portal Hacking and Forensics at Confidence 2013 - ERPScan

SAP Portal Hacking and Forensics at Confidence 2013 - ERPScan

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Invest in securityto secure investments<strong>SAP</strong> <strong>Portal</strong>: <strong>Hacking</strong> <strong>and</strong> forensicsDmitry Chastukhin – Director of <strong>SAP</strong> pentest/research teamEvgeny Neyolov – Security analyst, (anti)forensics research


<strong>ERPScan</strong>• Developing software for <strong>SAP</strong> security monitoring• Talks <strong>at</strong> 35+ security conferences worldwide: BlackH<strong>at</strong>(US/EU/DC/UAE), RSA, Defcon, CONFidence, HITB, etc.• First to develop software for NetWeaver J2EE assessment• The only solution to assess all areas of <strong>SAP</strong> Security• Research team with experience in different areas of securityfrom ERP <strong>and</strong> web security to mobile, embedded devices, <strong>and</strong>critical infrastructure, accumul<strong>at</strong>ing their knowledge on <strong>SAP</strong>research.Leading <strong>SAP</strong> AG partner in the field of discovering securityvulnerabilities by the number of found vulnerabilitieserpscan.com<strong>ERPScan</strong> — invest in security to secure investments2


<strong>SAP</strong>• The most popular business applic<strong>at</strong>ion• More than 180000 customers worldwide• More than 70% of Forbes 500 run <strong>SAP</strong>• More than 40% of ERP market in Pol<strong>and</strong>erpscan.com<strong>ERPScan</strong> — invest in security to secure investments5


<strong>SAP</strong> securityEspionage• Stealing financial inform<strong>at</strong>ion• Stealing corpor<strong>at</strong>e secrets• Stealing supplier <strong>and</strong> customer lists• Stealing HR d<strong>at</strong>aFraud• False transactions• Modific<strong>at</strong>ion of master d<strong>at</strong>aSabotage• Denial of service• Modific<strong>at</strong>ion of financial reports• Access to technology network (SCADA) by trust rel<strong>at</strong>ionserpscan.com<strong>ERPScan</strong> — invest in security to secure investments6


<strong>SAP</strong> security353025201510• BlackH<strong>at</strong>• Defcon• HITB• RSA• CONFidence• DeepSec• Hacktivity• Troopers• Source502003 2004 2005 2006 2007 2008 2009 2010 2011 2012 <strong>2013</strong>Source: <strong>SAP</strong> Security in Figures <strong>2013</strong>LINKerpscan.com<strong>ERPScan</strong> — invest in security to secure investments7


How easy? <strong>SAP</strong> Security NotesMore than 2600 in totalerpscan.com<strong>ERPScan</strong> — invest in security to secure investments8


Is it remotely exploitable?sapscan.com> 5000 non-web <strong>SAP</strong> services exposed in the worldincluding Disp<strong>at</strong>cher, Message server, SapHostControl, etc.erpscan.com<strong>ERPScan</strong> — invest in security to secure investments9


Wh<strong>at</strong> about other services?98World76543210<strong>SAP</strong> Disp<strong>at</strong>cher <strong>SAP</strong> MMC <strong>SAP</strong> Message Server <strong>SAP</strong> HostControl <strong>SAP</strong> ITS Ag<strong>at</strong>e <strong>SAP</strong> Message Serverhttpderpscan.com<strong>ERPScan</strong> — invest in security to secure investments10


Wh<strong>at</strong> about unpublished thre<strong>at</strong>s?• Companies are not interested in publishing inform<strong>at</strong>ion abouttheir breaches• There are a lot of internal breaches thanks to unnecessarilygiven authoriz<strong>at</strong>ions (An employee by mistake buys hundreds ofexcav<strong>at</strong>ors instead of ten)• There are known stories about backdoors left by developers incustom ABAP code• How can you be sure th<strong>at</strong>, if a breach occurs, you can findevidence?erpscan.com<strong>ERPScan</strong> — invest in security to secure investments11


<strong>SAP</strong> <strong>Forensics</strong>If there are no <strong>at</strong>tacks, it doesn’t mean anything• Companies don’t like to share it• Companies don’t use security audit ~10%• Even if used, nobody manages it ~5%• Even if managed, no correl<strong>at</strong>ion ~1%erpscan.com <strong>ERPScan</strong> — invest in security to secure investments12


Typical <strong>SAP</strong> audit options• ICM log icm/HTTP/logging_0 70%• Security audit log in ABAP 10%• Table access logging rec/client 4%• Message Server log ms/audit 2%• <strong>SAP</strong> G<strong>at</strong>eway access log 2%* The percentage of companies is based on our security assessments <strong>and</strong> productimplement<strong>at</strong>ions.erpscan.com <strong>ERPScan</strong> — invest in security to secure investments13


Wh<strong>at</strong> do we see?• A lot of research• Real <strong>at</strong>tacks• Lack of logging practice• Many vulnerabilities are hard to close → We need to monitorthem, <strong>at</strong> leasterpscan.com <strong>ERPScan</strong> — invest in security to secure investments14


Wh<strong>at</strong> do we need to monitor?External <strong>at</strong>tacks on <strong>SAP</strong>* Ideally, we should control everything, but this talk has limits, so let’s focus onthe most critical areas.Attack users <strong>and</strong> <strong>SAP</strong> GUI<strong>SAP</strong>routerExposed <strong>SAP</strong> services<strong>SAP</strong> <strong>Portal</strong> <strong>and</strong> WEBAwarenessSecure configur<strong>at</strong>ion <strong>and</strong> p<strong>at</strong>ch managementDisable them•Too much issues <strong>and</strong> customconfigur<strong>at</strong>ion•Can be 0-days•Need to concentr<strong>at</strong>e on this areaerpscan.com <strong>ERPScan</strong> — invest in security to secure investments15


Say hello to <strong>Portal</strong>• Point of web accessto <strong>SAP</strong> systems• Point of web access toother corpor<strong>at</strong>e systems• Way for <strong>at</strong>tackersto get access to <strong>SAP</strong>from the Interneterpscan.com <strong>ERPScan</strong> — invest in security to secure investments16


EP architectureerpscan.com <strong>ERPScan</strong> — invest in security to secure investments17


Okay, okay. <strong>SAP</strong> <strong>Portal</strong> is important, <strong>and</strong>it has many links to other modules.So wh<strong>at</strong>?erpscan.com <strong>ERPScan</strong> — invest in security to secure investments18


<strong>SAP</strong> Logging“If you are running an ABAP + Java install<strong>at</strong>ion of Web AS with<strong>SAP</strong> Web Disp<strong>at</strong>cher as a load balancing solution, you can safelydisable logging of HTTP requests <strong>and</strong> responses on J2EE Engine,<strong>and</strong> use the corresponding CLF logs of <strong>SAP</strong> Web Disp<strong>at</strong>cher. Thisalso improves the HTTP communic<strong>at</strong>ion performance. The onlydrawback of using the Web Disp<strong>at</strong>cher’s CLF logs is th<strong>at</strong> noinform<strong>at</strong>ion is available about the user executing the request(since the user is not authentic<strong>at</strong>ed on the Web Disp<strong>at</strong>cher, buton the J2EE Engine instead).“SOURCE: <strong>SAP</strong> HELP*Not the only…. There are many complex <strong>at</strong>tacks with POST requests.erpscan.com <strong>ERPScan</strong> — invest in security to secure investments19


<strong>SAP</strong> J2EE Logging• C<strong>at</strong>egories of system events recording:– System – all system rel<strong>at</strong>ed security <strong>and</strong> administr<strong>at</strong>ive logs– Applic<strong>at</strong>ions – all system events rel<strong>at</strong>ed to business logic– Performance – reserved for single activity tracing• Default loc<strong>at</strong>ion of these files in your file system:\usr\sap\\\j2ee\cluster\\log\erpscan.com <strong>ERPScan</strong> — invest in security to secure investments20


<strong>SAP</strong> J2EE Logging• The developer trace files of the Java instance\\work• The developer trace files of the central services\\work\\log• Java server logs\\j2ee\cluster\server\logerpscan.com <strong>ERPScan</strong> — invest in security to secure investments21


Full logging is not always the best option•erpscan.com <strong>ERPScan</strong> — invest in security to secure investments22


<strong>SAP</strong> Management Consoleerpscan.com <strong>ERPScan</strong> — invest in security to secure investments23


<strong>SAP</strong> Management Console• <strong>SAP</strong> MMC: centralized system management• <strong>SAP</strong> MMC has remote comm<strong>and</strong>s• Comm<strong>and</strong>s are simple SOAP requests• Allowing to see the trace <strong>and</strong> log messages• It’s not bad if you only use it sometimes <strong>and</strong> delete logs afteruse, but…erpscan.com <strong>ERPScan</strong> — invest in security to secure investments24


<strong>SAP</strong> Management ConsoleWh<strong>at</strong> can we find in logs?Right!The file userinterface.log contains calcul<strong>at</strong>ed JSESIONIDBut…The <strong>at</strong>tacker must have credentials to read the log fileWRONG!erpscan.com <strong>ERPScan</strong> — invest in security to secure investments25


<strong>SAP</strong> Management Consoletruej2ee/cluster/server0/log/system/userinterface.log%COUNT%EOFerpscan.com <strong>ERPScan</strong> — invest in security to secure investments26


Prevention• Don’t use TRACE_LEVEL = 3• Delete traces when work is finished• Limit access to dangerous methods• Install notes 927637 <strong>and</strong> 1439348• Mask security-sensitive d<strong>at</strong>a in HTTP access logLINK to <strong>SAP</strong> HELPerpscan.com <strong>ERPScan</strong> — invest in security to secure investments27


Prevention• The HTTP Provider service can mask securitysensitiveURL parameters, cookies, or headers• By default, only for the headers listed below– P<strong>at</strong>h Parameter: jsessionid– Request Parameters: j_password, j_username,j_sap_password, j_sap_again, oldPassword,confirmNewPassword,ticket– HTTP Headers: Authoriz<strong>at</strong>ion, Cookie (JSESSIONID,MY<strong>SAP</strong>SSO2)LINK to <strong>SAP</strong> HELPerpscan.com <strong>ERPScan</strong> — invest in security to secure investments28


<strong>SAP</strong> NetWeaver J2EEerpscan.com <strong>ERPScan</strong> — invest in security to secure investments29


web.xmlCriticalActioncom.sap.admin.Critical.ActionCriticalAction


Verb Tampering• If we are trying to get access to an applic<strong>at</strong>ion using GET – weneed a login:pass <strong>and</strong> administr<strong>at</strong>or role• Wh<strong>at</strong> if we try to get access to applic<strong>at</strong>ion using HEAD insteadGET?• PROFIT!• Did U know about ctc?erpscan.com <strong>ERPScan</strong> — invest in security to secure investments33


Verb TamperingNeed Admin account in <strong>SAP</strong> <strong>Portal</strong>?Just send two HEAD requests• Cre<strong>at</strong>e new user CONF:idenceHEAD /ctc/ConfigServlet?param=com.sap.ctc.util.UserConfig;CREATEUSER;USERNAME=CONF,PASSWORD=idence• Add the user CONF to the group Administr<strong>at</strong>orsHEAD /ctc/ConfigServlet?param=com.sap.ctc.util.UserConfig;ADD_USER_TO_GROUP;USERNAME=CONF,GROUPNAME=Administr<strong>at</strong>ors* Works when UME uses JAVA d<strong>at</strong>abase.erpscan.com <strong>ERPScan</strong> — invest in security to secure investments34


Prevention• Install <strong>SAP</strong> notes 1503579, 1616259, 1589525,1624450• Install other <strong>SAP</strong> notes about Verb Tampering• Scan applic<strong>at</strong>ions with <strong>ERPScan</strong> WEB.XMLchecker• Disable the applic<strong>at</strong>ions th<strong>at</strong> are not necessaryerpscan.com <strong>ERPScan</strong> — invest in security to secure investments35


Investig<strong>at</strong>ion[Apr 3, <strong>2013</strong> 1:23:59 AM ] - 192.168.192.14: GET /ctc/ConfigServlet HTTP/1.1 401 1790[Apr 3, <strong>2013</strong> 1:30:01 AM ] - 192.168.192.14: HEAD /ctc/ConfigServlet HTTP/1.1 200 0[Apr 3, <strong>2013</strong> 1:30:01 AM ] - 192.168.192.14: HEAD/ctc/ConfigServlet?param=com.sap.ctc.util.UserConfig;CREATEUSER;USERNAME=CONF,PASSWORD=idence HTTP/1.0 200 0j2ee\cluster\\log\system\httpaccess\responses.trcerpscan.com <strong>ERPScan</strong> — invest in security to secure investments36


web.xmlCriticalActioncom.sap.admin.Critical.ActionCriticalAction


Invoker Servlet• Want to execute an OS comm<strong>and</strong> on J2EE server remotely?• Maybe upload a backdoor in a Java class?• Or sniff all traffic?Still remember ctc?erpscan.com <strong>ERPScan</strong> — invest in security to secure investments38


Invoker Servleterpscan.com <strong>ERPScan</strong> — invest in security to secure investments39


Prevention• Upd<strong>at</strong>e to the l<strong>at</strong>est p<strong>at</strong>ch 1467771, 1445998• “EnableInvokerServletGlobally” must be “false”• Check all WEB.XML files with <strong>ERPScan</strong> WEBXMLcheckererpscan.com <strong>ERPScan</strong> — invest in security to secure investments40


Investig<strong>at</strong>ion#1.5#000C29C2603300790000003A000008700004D974E7CCC6D8#1364996035203#/System/Security/Audit#sap.com/tc~lm~ctc~util~basic_ear#com.sap.security.core.util.SecurityAudit#Guest#0#<strong>SAP</strong> J2EE Engine JTATransaction :[024423a006e18]#n/a##217c5d309c6311e29bca000c29c26033#<strong>SAP</strong>Engine_Applic<strong>at</strong>ion_Thread[impl:3]_22##0#0#Info#1#com.sap.security.core.util.SecurityAudit#Plain###Guest | USER.CREATE |USER.PRIVATE_DATASOURCE.un:CONF | | SET_ATTRIBUTE:uniquename=[CONF]##1.5#000C29C2603300680002C97A000008700004D974E8354D1D#1364996042062#/System/Security/Audit/J2EE#sap.com/irj#com.sap.engine.services.security.roles.audit#Guest#182818##n/a##0c5bfef08bc511e287e6000c29c26033#Thread[Thread-50,5,<strong>SAP</strong>Engine_Applic<strong>at</strong>ion_Thread[impl:3]_Group]##0#0#Info#1#com.sap.engine.services.security.roles.audit#Java###{0}:Authoriz<strong>at</strong>ion check for caller assignment to J2EE security role[{1} : {2}].#3#ACCESS.OK#<strong>SAP</strong>-J2EE-Engine#guests#erpscan.com <strong>ERPScan</strong> — invest in security to secure investments41


Investig<strong>at</strong>ionerpscan.com <strong>ERPScan</strong> — invest in security to secure investments41


XSS• Many XSSs in <strong>Portal</strong>• But sometimes HttpOnly• But when we exploit XSS, we can use the fe<strong>at</strong>ures of <strong>SAP</strong> <strong>Portal</strong>EPCFerpscan.com <strong>ERPScan</strong> — invest in security to secure investments43


EPCF• EPCF provides a JavaScript API designed for the client-sidecommunic<strong>at</strong>ion between portal components <strong>and</strong> the portal coreframework• Enterprise <strong>Portal</strong> Client Manager (EPCM)• iViews can access the EPCM object from every portal pageor IFrame• Every iView contains the EPCM objectalert(EPCM.loadClientD<strong>at</strong>a("urn:com.sap.myObjects", "person");For example, EPCF used for transient user d<strong>at</strong>a buffer for iViewserpscan.com <strong>ERPScan</strong> — invest in security to secure investments44


Prevention• Install <strong>SAP</strong> note 1656549erpscan.com <strong>ERPScan</strong> — invest in security to secure investments45


Investig<strong>at</strong>ion#Plain###192.168.192.26 : GET/irj/servlet/prt/portal/prtroot/com.sap.portal.usermanagement.admin.UserMapping?systemid=MS_EXCHANGEaaaa%3C/script%3E%3Cscript%3Ealert(%27xSS%27)%3C/script%3E HTTP/1.1 200 3968#j2ee\cluster\\log\system\httpaccess\responses.trcerpscan.com <strong>ERPScan</strong> — invest in security to secure investments46


Web Dynpro JAVA• Web Dynpro unauthorized modific<strong>at</strong>ions• For example:– somebody steals an account using XSS/CSRF/Sniffing– then tries to modify the severity level of logserpscan.com <strong>ERPScan</strong> — invest in security to secure investments47


Web Dynpro JAVALINK to <strong>SAP</strong> HELPerpscan.com <strong>ERPScan</strong> — invest in security to secure investments48


Investig<strong>at</strong>ion• No traces of change in default log files\cluster\server0\log\system\httpaccess\responses.log• Web Dynpro sends all d<strong>at</strong>a by POST, <strong>and</strong> we only see GET URLs inresponses.log• But sometimes we can find inform<strong>at</strong>ion by indirect signs[Mar 20, <strong>2013</strong> 9:35:49 AM ] - 172.16.0.63 : GET/webdynpro/resources/sap.com/tc~lm~webadmin~log_config~wd/Components/com.sap.tc.log_configur<strong>at</strong>or.LogConfigur<strong>at</strong>or/warning.gif HTTP/1.1 200 110• The client loaded images from the server during some changeserpscan.com <strong>ERPScan</strong> — invest in security to secure investments49


Investig<strong>at</strong>ion• Most actions have icons• They have to be loaded from the server• Usually, legitim<strong>at</strong>e users have them all in cache• Attackers usually don’t have them, so they make requests to theserver• Th<strong>at</strong>’s how we can identify potentially malicious actions• But there should be correl<strong>at</strong>ion with a real user’s activity• False positives are possible:– New legitim<strong>at</strong>e user– Old user clears cache– Othererpscan.com <strong>ERPScan</strong> — invest in security to secure investments50


Directory traversalFIXerpscan.com <strong>ERPScan</strong> — invest in security to secure investments51


Directory traversal fix bypasserpscan.com <strong>ERPScan</strong> — invest in security to secure investments52


Prevention• Install <strong>SAP</strong> note 1630293erpscan.com <strong>ERPScan</strong> — invest in security to secure investments53


Investig<strong>at</strong>ion/../!252f..!252ferpscan.com <strong>ERPScan</strong> — invest in security to secure investments54


Breaking <strong>SAP</strong> <strong>Portal</strong>• Found a file in the OS of <strong>SAP</strong> <strong>Portal</strong> with the encryptedpasswords for administr<strong>at</strong>ion <strong>and</strong> DB• Found a file in the OS of <strong>SAP</strong> <strong>Portal</strong> with keys to decryptpasswords• Found a vulnerability (another one ;)) which allows reading thefiles with passwords <strong>and</strong> keys• Decrypt passwords <strong>and</strong> log into <strong>Portal</strong>• PROFIT!erpscan.com <strong>ERPScan</strong> — invest in security to secure investments55


Read the fileHow can we read the file?• Directory Traversal• OS Comm<strong>and</strong> execution• XML External Entity (XXE)erpscan.com <strong>ERPScan</strong> — invest in security to secure investments56


XXE in <strong>Portal</strong>: Details• Injection of malicious requests into XML packets• Can lead to unauthorized file read, DoS, SSRF• There is an XXE vulnerability in <strong>SAP</strong> <strong>Portal</strong>• Can be exploited by modific<strong>at</strong>ion of POST request• It is possible to read any file from OS <strong>and</strong> much moreerpscan.com <strong>ERPScan</strong> — invest in security to secure investments57


XXE in <strong>Portal</strong>erpscan.com <strong>ERPScan</strong> — invest in security to secure investments58


XXE in <strong>Portal</strong>erpscan.com <strong>ERPScan</strong> — invest in security to secure investments59


XXEError based XXEerpscan.com <strong>ERPScan</strong> — invest in security to secure investments60


XXE in <strong>Portal</strong>: Result• We can read any file• Including config with passwords• The <strong>SAP</strong> J2EE Engine stores the d<strong>at</strong>abase user <strong>SAP</strong>DB; itspassword is here:\usr\sap\\SYS\global\security\d<strong>at</strong>a\SecStore.propertieserpscan.com <strong>ERPScan</strong> — invest in security to secure investments61


Where are the passwords?(config.properties)rdbms.maximum_connections=5system.name=TTTsecstorefs.keyfile=/oracle/TTT/sapmnt/global/security/d<strong>at</strong>a/SecStore.keysecstorefs.secfile=/oracle/TTT/sapmnt/global/security/d<strong>at</strong>a/SecStore.propertiessecstorefs.lib=/oracle/TTTsapmnt/global/security/librdbms.driverLoc<strong>at</strong>ion=/oracle/client/10x_64/instantclient/ojdbc14.jarrdbms.connection=jdbc/pool/TTTrdbms.initial_connections=1erpscan.com <strong>ERPScan</strong> — invest in security to secure investments62


Where are the passwords?(config.properties)rdbms.maximum_connections=5system.name=TTTsecstorefs.keyfile=/oracle/TTT/sapmnt/global/security/d<strong>at</strong>a/SecStore.keysecstorefs.secfile=/oracle/TTT/sapmnt/global/security/d<strong>at</strong>a/SecStore.propertiessecstorefs.lib=/oracle/TTTsapmnt/global/security/librdbms.driverLoc<strong>at</strong>ion=/oracle/client/10x_64/instantclient/ojdbc14.jarrdbms.connection=jdbc/pool/TTTrdbms.initial_connections=1erpscan.com <strong>ERPScan</strong> — invest in security to secure investments63


SecStore.properties$internal/version=Ni4zFF4wMSeaseforCCMxegAfxadmin/host/TTT=7KJuOPPs/+u+14jM7uy7cy7exrZuYvevkSrPxwueur2445yxgBSadmin/password/TTT=7KJuOPPs/+uv+14j56vDc7M7v7dytbGbkgqDp+QD04b0Fhjdbc/pool/TTT=7KJuOPPs/+u5jM6s1cvvgQ1gzFvarxuUzEJTHTJI0VGegHBut where is the key?admin/port/TTT=7KJuOPPs/+u+1j4vD1cv6ZTvd336rzEd7267Rwr4ZUgRTQ$internal/check=BJRrzfjeUA+bw4XCzdz16zX78ufbt$internal/mode=encryptedadmin/user/TTT=7KJuOPPs/+u+14j6s14sTxXU3ONl3rL6N7yssV75eC6/5S3Eerpscan.com <strong>ERPScan</strong> — invest in security to secure investments64


config.propertiesrdbms.maximum_connections=5system.name=TTTsecstorefs.keyfile=/oracle/TTT/sapmnt/global/security/d<strong>at</strong>a/SecStore.keysecstorefs.secfile=/oracle/TTT/sapmnt/global/security/d<strong>at</strong>a/SecStore.propertiessecstorefs.lib=/oracle/TTTsapmnt/global/security/librdbms.driverLoc<strong>at</strong>ion=/oracle/client/10x_64/instantclient/ojdbc14.jarrdbms.connection=jdbc/pool/TTTrdbms.initial_connections=1erpscan.com <strong>ERPScan</strong> — invest in security to secure investments65


Get the password• We have an encrypted password• We have a key to decrypt itWe got the J2EE admin <strong>and</strong> JDBClogin:password!erpscan.com <strong>ERPScan</strong> — invest in security to secure investments66


Prevention• Install <strong>SAP</strong> note 1619539• Restrict read access to files SecStore.properties<strong>and</strong> SecStore.keyerpscan.com <strong>ERPScan</strong> — invest in security to secure investments67


Investig<strong>at</strong>ionPOST/irj/servlet/prt/portal/prteventname/HtmlbEvent/prtroot/pcd!3aportal_content!2fadministr<strong>at</strong>or!2fsuper_admin!2fsuper_admin_role!2fcom.sap.portal.content_administr<strong>at</strong>ion!2fcom.sap.portal.content_admin_ws!2fcom.sap.km.AdminContent!2fcom.sap.km.AdminContentExplorer!2fcom.sap.km.AdminExplorer/ HTTP/1.1erpscan.com <strong>ERPScan</strong> — invest in security to secure investments68


Investig<strong>at</strong>ion• The only one way to get HTTP POST request values is to enableHTTP Trace• Visual Administr<strong>at</strong>or → Disp<strong>at</strong>cher → HTTP Provider→ Properties: HttpTrace = enable• For 6.4 <strong>and</strong> 7.0 SP12 <strong>and</strong> lower:– On Disp<strong>at</strong>cher:/j2ee/cluster/disp<strong>at</strong>cher/log/defaultTrace.trc– On Server\j2ee\cluster\server0\log\system\httpaccess\responses.0.trc• For 7.0 SP13 <strong>and</strong> higher:/j2ee/cluster/disp<strong>at</strong>cher/log/services/http/req_resp.trc• Manually analyze all requests for XXE <strong>at</strong>tackserpscan.com <strong>ERPScan</strong> — invest in security to secure investments69


Malicious file upload: Attack• Knowledge management allows uploading to the serverdifferent types of files th<strong>at</strong> can store malicious content• Sometimes, if guest access is allowed, it is possible to uploadany file without being an authentic<strong>at</strong>ed user• For example, it can be an HTML file with JavaScript th<strong>at</strong> stealscookieserpscan.com <strong>ERPScan</strong> — invest in security to secure investments70


Malicious file upload: Attackerpscan.com <strong>ERPScan</strong> — invest in security to secure investments71


Malicious file upload: Attackerpscan.com <strong>ERPScan</strong> — invest in security to secure investments72


Malicious file upload: <strong>Forensics</strong>[Apr 10, <strong>2013</strong> 2:26:13 AM ] - 192.168.192.22 : POST/irj/servlet/prt/portal/prteventname/HtmlbEvent/prtroot/pcd!3aportal_content!2fspecialist!2fcontentmanager!2fContentManager!2fcom.sap.km.ContentManager!2fcom.sap.km.ContentExplorer!2fcom.sap.km.ContentDocExplorer!2fcom.sap.km.DocsExplorer/documentsHTTP/1.1 200 13968[Apr 10, <strong>2013</strong> 2:26:14 AM ] - 192.168.192.22 : GET/irj/go/km/docs/etc/public/mimes/images/html.gifHTTP/1.1 200 165*Again, images can help us.erpscan.com <strong>ERPScan</strong> — invest in security to secure investments73


Malicious file upload: PreventionEnable File Extension <strong>and</strong> Size Filter:• System Administr<strong>at</strong>ion → System Configur<strong>at</strong>ion →Content Management → Repository → Filters → ShowAdvanced Options → File Extension <strong>and</strong> Size Filter• Select either the All repositories parameter or <strong>at</strong> leastone repository from the repository list inthe Repositories parametererpscan.com <strong>ERPScan</strong> — invest in security to secure investments74


Malicious file upload: PreventionEnable Malicious Script Filter:• System Administr<strong>at</strong>ion → System Configur<strong>at</strong>ion →Content Management → Repository → Filters → ShowAdvanced Options → Malicious Script Filter• The filter also detects executable scripts in files th<strong>at</strong> arebeing modified <strong>and</strong> encodes them when they are saved– enable Forbidden Scripts. Comma-separ<strong>at</strong>ed list of bannedscript tags th<strong>at</strong> will be encoded when the filter is applied– enable the Send E-Mail to Administr<strong>at</strong>or optionerpscan.com <strong>ERPScan</strong> — invest in security to secure investments75


<strong>Portal</strong> post-exploit<strong>at</strong>ion• Lot of links to other systems in corpor<strong>at</strong>e LAN• Using SSRF, <strong>at</strong>tackers can get access to these systemsWh<strong>at</strong> is SSRF?erpscan.com <strong>ERPScan</strong> — invest in security to secure investments76


SSRF History: Basics• We send Packet A to Service A• Service A initi<strong>at</strong>es Packet B to service B• Services can be on the same or different hosts• We can manipul<strong>at</strong>e some fields of packet B within packet A• Various SSRF <strong>at</strong>tacks depend on how many fields we can controlon packet BPacket APacket Berpscan.com <strong>ERPScan</strong> — invest in security to secure investments77


Partial Remote SSRF:HTTP <strong>at</strong>tacks on other servicesCorpor<strong>at</strong>enetworkHTTP ServerDirect <strong>at</strong>tackGET /vuln.jspSSRF AttackGet /vuln.jstSSRF AttackABerpscan.com <strong>ERPScan</strong> — invest in security to secure investments78


Gopher uri scheme• Using gopher:// uri scheme, it is possible to send TCPpackets– Exploit OS vulnerabilities– Exploit old <strong>SAP</strong> applic<strong>at</strong>ion vulnerabilities– Bypass <strong>SAP</strong> security restrictions– Exploit vulnerabilities in local servicesMore info in our BH2012 present<strong>at</strong>ion:SSRF vs. Business Critical Applic<strong>at</strong>ionsLINKerpscan.com <strong>ERPScan</strong> — invest in security to secure investments79


<strong>Portal</strong> post-exploit<strong>at</strong>ionerpscan.com <strong>ERPScan</strong> — invest in security to secure investments80


Anti-forensicserpscan.com <strong>ERPScan</strong> — invest in security to secure investments81


Anti-forensics• Flooding• Deleting• Changingerpscan.com <strong>ERPScan</strong> — invest in security to secure investments82


Anti-forensicsLog flooding• 5 active logs• Maximum log file size is 10 Mb• Archiving when all logs reach the maximum size• If file.0.log -> max size then open file.1.log• If file.4.log -> max size then zip all <strong>and</strong> backup• Rewriting the same files after archivingerpscan.com <strong>ERPScan</strong> — invest in security to secure investments83


Anti-forensicsLog deleting• <strong>SAP</strong> locks write access to the only one active log• <strong>SAP</strong> allows reading/writing logs, so it is possible to delete them• It could compromise the <strong>at</strong>tacker’s presenceLog changing• <strong>SAP</strong> locks write access only to the one active log• It is possible to write into any other log fileerpscan.com <strong>ERPScan</strong> — invest in security to secure investments84


Securing <strong>SAP</strong> <strong>Portal</strong>• P<strong>at</strong>ching• Secure configur<strong>at</strong>ion• Enabling HTTP Trace with masking• Malicious script filter• Log archiving• Additional place for log storage• Monitoring of security events– Own scripts, parse common p<strong>at</strong>terns– <strong>ERPScan</strong> has all existing web vulns/0-day p<strong>at</strong>ternserpscan.com <strong>ERPScan</strong> — invest in security to secure investments85


ConclusionIt is possible to protect yourself from these kinds of issues,<strong>and</strong> we are working close with <strong>SAP</strong> to keep customers secure<strong>SAP</strong> GuidesRegular security assessmentsMonitoring technical securityABAP code reviewSegreg<strong>at</strong>ion of DutiesSecurity events monitoringIt’s all in your h<strong>and</strong>s


Future workI'd like to thank <strong>SAP</strong>'s Product Security Response Team for thegre<strong>at</strong> cooper<strong>at</strong>ion to make <strong>SAP</strong> systems more secure. Researchis always ongoing, <strong>and</strong> we can't share all of it today. If you wantto be the first to see new <strong>at</strong>tacks <strong>and</strong> demos, follow us <strong>at</strong>@erpscan <strong>and</strong> <strong>at</strong>tend future present<strong>at</strong>ions:• July 31 – BlackH<strong>at</strong> (Las Vegas, USA)erpscan.com <strong>ERPScan</strong> — invest in security to secure investments87


Web:www.erpscan.come-mail: info@erpscan.comTwitter:@erpscan@_chipik@neyolov

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!