58
Build Your Application in a Cloud. Make It Safe! Deadline? Tomorrow! Tomasz Onyszko CTO, Co-Founder Predica Sp. z o.o.

Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Build Your Application in a Cloud. Make It Safe! Deadline? Tomorrow!

Tomasz OnyszkoCTO, Co-Founder

Predica Sp. z o.o.

Page 2: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

• Internation comapny based in US, Poland (HQ)

and Middle East

• 150+ consultants in 5 countries

• Projects delivered in 20+ countries on 3

continents

Page 3: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

• Predica – CTO and co-founder

• (almost) 20 years in IT business

• MVP (since 2005 ... with short break)

• blogger: https://onyszko.com

• video: https://predica.pl (and our YT channel)

• twitter: @tonyszko

Page 4: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

GOAL: Learn how to build secure application on Azure cloud using cloud services and architecture patterns!

Page 5: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

What does it mean that application is secure?

SECURE – is it the same for everyone?

How do we know what to tacle and how?

Page 6: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Azure Security more than one aspect

• IaaS• Virtual machines, networking and its environment

• PaaS• Services provided by the platform with code deployed

• Mix• PaaS services based on infrastructure (e.g. AKS)

Page 7: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

It is a lot of moving parts!

Page 8: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 9: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Azure is a sandpit!

• Who can enter a sandpit?

• Who can build sand castles and in which region?

• What sand resources are available and who can use it for what purpose ?

Page 10: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 11: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

How Azure is built and who controls it!?!

• Subscription == „sandpit”

• Resources groups within subscriptions == „sand resources”

• Single organization can (and will) have many subscriptions (and will have to manage it)

Page 12: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Azure Active Directory - Gatekeeper

Page 13: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Azure AD

• Directory and more• Directory object store

• Unigied authentication and authorization service with scale

• In a context of Azure• Azure is just another app

• Azure resources access controled through Azure AD

• Role based security mode

User

Application

Groups

Role

Page 14: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

RBAC

• Roles are defined at the level of• Subscriptions

• Resource groups

• Scope• Default

• Custom (defined within organisation)

• HINTs:• Do not use MSA accounts to grant access

• Group -> Role (avoid direct user to role assignment)

Page 15: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 16: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Lets build THE APPLICATION!

Page 17: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 18: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Simple case: Web Application

• What you need to provide?• Security context used by application

• Application permissions to access resources

• Authentication service for users

• How to deal with sensitive materials (connection strings, certs, passwords)

• HOW?

Page 19: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Security context

• Each application has two Azure AD objects• Application

• Service Principal

• Application (definition)• App metadata and configuration

• Service principal• App representation within particular tenant

Service principal

Application

Page 20: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Service Principal

• Why we need it ?!?

• Multi-tenant applications• Obsługuje użytkowników w wielu AAD

• Application object exists within original tenant

• Each tenant using an app has service principal

• Service principal• Local tenant user assinments and app permissions

• Local application branding

• Additional permissions and settings local for the tenant

Page 21: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 22: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Dear app, How DO I know it is YOU?

• Application credentials• ClientID (login)

• Secret (password)

• ClientID• Form of GUID, created once upon app creation

• Secret• Application key, can be created on request

• Each key has its validity perio

Page 23: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 24: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

• Client Secret – problem!• How to deal with its expiration?

• How to protect it?

• What to do if someone will capture it?

• What if someone will commit it to VSTS/GitHub?

Page 25: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Managed Service Identity (MSI)

• Application and Service principal managed by Azure platform• Application keys managed and rolled-over by Azure

• You don’t need to generate and manage app credentials

• Credentials usage (access)• Through API and libraries from code

• Environment variables

Page 26: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

MSI – where you can use it?

• IaaS (virtual machine identity)

• App Service

• Azure Function

• Azure Data Factory v2

Page 27: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

MSI – what supports it?

• Azure Resource Manager (ARM)

• Key Vault

• Data Lake

• Azure SQL

• Event Hub

• Service Bus

Page 28: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 29: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

How Azure Function should connct to database!?!

?

Page 30: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 31: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Azure KeyVault

• Service to store, manage and access• Passwords, keys, certificates, secrets (connection strings)

• Up to 10kB

• HSM (in Premium tier) accessible through API• Access is controled at Azure AD level

• Fully audited with access audit trail

Page 32: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Azure KeyVault in an APP

Connection string

Page 33: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 34: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Key Vault – Access control

• Controled on instance level (vault) • Multiple vaults will exists within single subscription

• Based on Azure RBAC model

• Permissions can be granted• For user, group or role (preffered)

• For application (service principal)

Page 35: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Key Vault – practical tips

• KeyVault is security boundary! • If we have separate security domains within app lets

separate Key Vaults for them

• Performance• Each operation on KeyVault is REST API call

• With large volume of calls it can hit your performance

• Think about caching at the application level

Admin portal Ogólny web

MSI MSI

Admin portal Ogólny web

MSI MSI

Page 36: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 37: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Applications today

User Browser

Native apps

Server apps

User

Web App

API

API

API

Page 38: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Applications today … in practice (real case)

User

Browser Web App API

Username and password

Basich HTTP Auth

Authorization key

Key crafted by hand for each “customer” and

passed in URL

Fixed service account

Page 39: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 40: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 41: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 42: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

OAuth 2.0 for beginners

• It is protocol „framework” for authorization, sets protocol flows

• Authorization protocol designed to authorize “resources” access (mostly API)

o It doesn’t enforce and sets standard for authentication

o It doesn’t enforce or specify token validation

• OAuth token is designated for API, not to be consumed by application

o Access Token

o Refresh Token

• Specifies several protocol flows based on client and scenarios

Page 43: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

OAuth trouble

• It is not authentication protocol

o And it is important distinction

• It is not strict protocol, details will vary (like scopes)

• Token security

o Security of refresh token

o Token hijacking

• Proof Key for Token Exchange

• Token binding

Page 44: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

OpenID Connect for beginners

• Based on OAuth 2.0

o Federation protocol

o Based on JWT

• It is authentication protocol, specified ID Token

o Standard scopes

o Introduces user info endpoint

• Standard way of token validation and verification

o Discovery endpoint

Page 45: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

OpenID Connect at a glance

• Solves authentication problem for client

o Dedicated identity token

o Well defined requirements for authentication and token validation

• Scalable

o Discovery endpoint

• Based on OAuth 2.0

o Support all Oauth 2.0 authorization flows

• Ineterop!! - http://openid.net/certification/

Page 46: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Identity as a Service (IdaaS)

Page 47: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Identity != Authorization

Page 48: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Troubles with authorization

• Identity provider does not have all the knowledge about apps and

permissions

o Authorization process should be performed close to the resources

• Once issued token can be re-used in various places

o Single token used in different contexts

• Permissions are changing, tokens might live long

o Token revocation problem

Page 49: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Token re-use problem

API

API

API

Identity provider

Page 50: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Trouble with authorization continued

• There is more than one permission in an application

o Permissions for client to access API

o Permissions for user to use application function

o Permissions for user to use API functions

o Permissions for user at data level

o Uprawnienia użytkownika na poziomie danych

• Different syntax and semantics of permissions at different layers

Page 51: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Bloated token{

"iss": "https://idp",

"aud": [ "api1" ," api1"],

"alg": "HS256",

"amr": [ "password" ],

"auth_time": 1234567890,

"typ": "JWT"

"sub": "1234567890",

"name": "John Doe",

"admin": true

"role": [

"Approver",

"Reviewer" ],

"permission:" [

"CreateRecord",

"ViewRecord",

"DeleteRecord",

"ApproveOrder" ]

}

metadata

Identity information

role

permission

Page 52: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

Authorization in apps

Authentication and token issuance

Client permission

Identity provider Authorization provider

API calls

API specific permissions

Page 53: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 54: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 55: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

In summary

• Application security is something you need to address at the design level• Identify threats, address risks

• Address most important aspects first!

• Azure platform• Provides complete security model for applications (with some

details still to be addresses)

• Provides services which address many security aspects

Page 56: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

We even haven’t started to talk about …

• Infrastructure

• Encryption

• Data at rest

• Data in transit

• Within services

• Audit and monitoring

• Handling user identity (consumer and other security aspects)

Page 57: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!
Page 58: Build Your Application in a Cloud. Make It Safe! Deadline? …files.informatandm.com/uploads/2018/10/Build_Your... · 2018-10-14 · Build Your Application in a Cloud. Make It Safe!

THANK YOU!

More, not only on security?

https://predica.pl/blog/

Tomasz OnyszkoCTO, Co-Founder

Predica Sp. z o.o.