51
Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo Artuso, Nahuel D. Sánchez

Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

Dark Clouds ahead: Attacking a Cloud Foundry Implementation

March 2019 - TROOPERS 19, Heidelberg - Germany

Pablo Artuso, Nahuel D. Sánchez

Page 2: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

Page 3: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

3

Pablo ArtusoNahuel D. Sánchez

● Focus on vulnerability research and ERP security

● Trainers & speakers at Security conferences

● Frequent vulnerability reporters for SAP products

● https://www.onapsis.com

Page 4: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

4

● Cloud Foundry

● SAP HANA and XSA

● Our Research

● Conclusions

Page 5: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

Cloud foundry

Page 6: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

6

“...It is an open source platform that you can deploy to run your apps on your own computing infrastructure, or deploy on an IaaS like AWS, vSphere, or OpenStack…”

Cloudfoundry?

● Abstraction● Scalability● Simplicity of use

https://docs.cloudfoundry.org/concepts/overview.html

Page 7: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

7

Not all clouds are equal

Page 8: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

8

Routes traffic to the appropriate component

Provides user authentication services

Orchestrates application deployment and maintains track of organizations, user roles and other...

Provides Access to 3rd party services to deployed applications● Database Access● File system Storage● Others...

Page 9: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

9

Pivotal, Atos, Cloud.gov, IBM, SAP, others...

Page 10: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

Organization (y)

10

Space (x)

App.

“Service wiring”OS env variables

{... user: … pass: ……}

Binding

● Platform users can have different permissions in different spaces (think in dev space/prod space)

● Privileges are grouped into “scopes”, each component have their our scopes (UAA, scopes, Controller Scopes, and so on)

● Roles are a group of scopes. There are some default roles such as: Admin, Org manager, Auditor and others...

https://docs.cloudfoundry.org/concepts/roles.htmlhttps://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.00/en-US/df19a03dc07e4ba19db4e0006c1da429.html

Service Instance

Service Broker

Cloud Controller

user / password

Page 11: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

SAP HANA and XSA

Page 12: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

12

● SAP HANA?○ In memory database

● XS Engine (Classic)○ Embedded web server (now deprecated)

● Application platform○ XS Advanced○ In the cloud, provided by Cloud Foundry○ On premise, provided by SAP (Cloud Foundry

compatible)

Page 13: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

13

XSA Cloud foundry

Page 14: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

14

Client Service Port (dest) Usage

Applications UI xsuaaserver 3xx32 Client App -> XS Web disp (Auth)

CMD cli / Cli libs / others xscontroller 3xx30 Connections to the xscontroller (Data access)

Applications UI App Instances 51000-51500 End users access Applications

App ports 51000-51500 App Instances 50000-50999 Connection from web disp to the target

xsexecagent xscontroller 3xx29 Connections from xs exec agent and the controller

Legend:Public portsInternal ports

https://testhelpportal.com/viewer/6b94445c94ae495c83a19646e7c3fd56/2.0.03/en-US/6b039ca5e9e44402bd86cafa53ea850b.html

Page 15: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

15

Page 16: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

Our research

Page 17: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

17

Page 18: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

18

● Manages spaces andorganizations.

● Provides several REST API’s to access and maintain the whole environment.

“The brain of the Cloud Foundry Environment”

Page 19: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

19

● API’s exposed● Internal

connections to exec agents

● Connection to DB

● Service Brokers

Page 20: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved20

● How to interact with them? ○ xs client

● Controller is shipped as jar file

● REST API’s Implemented using JAX-RS.

● Developed a parser:○ Identifies all data for each web

service .○ Uniform output for further

processing.○ Will go public at our github!

Page 21: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

21

● Organization isolation○ Administrative Level

● Space isolation○ Development Level○ Administrative Level○ OS Level

● Authorizations per Space & Organization● Application isolation

○ Bindings to services (i.e: DB)● ...

Page 22: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

22

“Auditors can view space/organization resources, excluding credentials”

OrgManager OrgAuditorOrganization

Space

SpaceManager

SpaceDeveloper

SpaceAuditor

Page 23: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

DEMO

Page 24: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

24

● Space least privileged user →got access to :○ Broker credentials○ Apps bindings credentials

Broke one of the protections mentioned:

Authorizations per SpacesPatched in SAP Security Note 2589129 CVE-2018-2375

Page 25: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

25

● API’s exposed● Internal

connections to exec agents

● Connection to DB

● Service Brokers

Page 26: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

26

● The Controller, UAA and applications need to interact with the DB.

● SYS_XS_RUNTIME is the owner at DB level of the schema of XSA

○ Catalog Read○ Inifile admin○ User Secure store (I,D,R)

Page 27: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

27

● Found endpoint which wasn’t sanitizing the input of a SQL statement.

● But..● Same input, multiple statements.

The only way we found was… calling him!

Page 28: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

DEMO

Page 29: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

29

● 1 vulnerable parameter of ..1 endpoint in … 1 API

● Unauthenticated attacker → Read SQL tables● Only read access. Nothing possible with the secstore.

○ Bindings○ Users

Patched in SAP Security Note 2589129 CVE-2018-2373

CVSS (v3): 5.3

Page 30: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

30

At the level of the Controller most of them ….

Can be circumvented!Although business data remains safe,

some technical data...

Page 31: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

31

Read controller’s schema (SYS_XS_RUNTIME)● Organizations, spaces, applications, services.● XSA users info (authorizations)● Source code of applications● Environment data of apps● ...

Read SYS schema ● System logs / users / configurations● Information about DB (OS, hosts, tenants)● ...

Page 32: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

32

Read controller’s schema (SYS_XS_RUNTIME)● Organizations, spaces, applications, services.● XSA users info (authorizations)● Source code of applications● Environment data of apps● ...

Read SYS schema ● System logs / users / configurations● Information about DB (OS, hosts, tenants)● ...

Page 33: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

● Environment data about each app.○ space○ id’s (droplet, instance, app, etc)○ services bound○ more...

● vcap_services is not there, but.. ● Passwords in plain text!

○ service brokers running as apps (users and passwords)

○ More passwords

33

Page 34: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

34

CREATE BIND UNBIND

MODIFY DELETE

Page 35: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

35

Page 36: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

● SAP Landscape Directory? (SLD)

● XSA exposes an authenticated way of sending data to the SLD.

● Only SpaceDeveloper’s of the SAP space can access them.

36

...

sldreg sldreg

SLD

SAP System

SAP System

Page 37: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

BUT …. ● Leveraging the SQLi the

credentials can be read

37

● External Entities were possible

● Data is sent using XML...

● The attacker can control the data sent to the SLD…

Page 38: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

38

Page 39: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

39

● Data is sent to the SLD! Not back to the user!and…

● XML lib doesn’t implemented http:// protocol!

● Again, we had to call..

Page 40: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

DEMO

Page 41: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

41

Patched in SAP SSN’s 2729710 & 2764283 CVE-2019-0277 , CVE-2019-0265

● XML lib was vulnerable to XXE.● In our case, no credentials needed.● “Only” DoS and OS file read was able as SIDadm user.

FROM A CLOUD APPLICATION TO THE OS!

Page 42: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

42

● Important files can be retrieved:

○ UAA files○ Tomcat logs○ Config files○ ...

● However, space isolation at OS level, worked very well.

Page 43: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

Recapping

Page 44: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

44

SAP System

XSA

SQL injection

user & password

Authenticated XXE(DoS)

Controller

Unauthenticated DareDevil

Page 45: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

45

SAP System

XSA

SQL injection

user & password

Authenticated XXE(XXE file://)

Unauthenticated DareDevil

Controller

OS File

asda 123123asdasdasdasdasdasdasdasdasdasdadasdsadsadsdsasdasdsda

sdsadsdasdasdsadasdassdsadsdasdasdsadasdassdsadsdasdasdsadasdassdsadsdasdasdsadasdassdsadsdasdasdsadasdas

asdasdsadsdasdasdasdadadsadsds2132

asda sa12123123

Super-hyper-duper confidential file

Page 46: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

Conclusions

Page 47: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

47

“In the land of the blind,

the one-eyed man is king”

Page 48: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

48

● Cloud is COMPLEX and, therefore, DIFFICULT.

● A little hole can open a big gap.

● Sometimes, CVSS can obscure impact.

Page 49: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

49

● Our research found other vulnerabilities too○ User enumerations○ Information disclosures○ More ...

● Future/ongoing research…○ Other components○ Connections between components○ Applications implementation

Page 50: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights Reserved

Questions?

Page 51: Implementation Dark Clouds ahead: Attacking a Cloud Foundry€¦ · Dark Clouds ahead: Attacking a Cloud Foundry Implementation March 2019 - TROOPERS 19, Heidelberg - Germany Pablo

@2019 Onapsis, Inc. All Rights ReservedMarch 2019 - Troopers 19, Heidelberg, Germany

Thank you!

@onapsis

[email protected]

www.onapsis.com

@partu18@nahueldsanchez_