securing serverless and container services...securing serverless and container services marc...

40
Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors

Upload: others

Post on 20-May-2020

26 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Securing Serverless and Container ServicesMarc SchröterAWS DevOps Engineer @ globaldatanet

Community Day 2019 Sponsors

Page 2: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

DevOps Automation

Continuous DeliveryInfrastructure as Code

Cloud Security

Security and Compliance Controls

Container

Managing the full container life cycle

Serverless

Highly scalable and fault-tolerant solutions

Page 3: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

What is serverless, and howdoes it impact your approachto security?

Page 4: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

What is serverless?

Shift operational responsibilities to AWS

Increasing your agility and innovation

Page 5: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

No infrastructure provisioning, no management Automatic scaling

Pay for value Highly available and secure

Page 6: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

COMPUTE

INTEGRATION

DATA STORES

AWS Lambda

AWS Fargate

AmazonS3

Amazon Aurora Serverless

AWS DynamoDB

AmazonAPI Gateway

AmazonSQS

AmazonSNS

AmazonStep Functions

Page 7: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation
Page 8: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Serverless Risks - OWASPA1: InjectionA2: Broken AuthenticationA3: Sensitive Data Exposure A4: XML External Entities (XXE) A5: Broken Access ControlA6: Security MisconfigurationA7: Cross-Site Scripting (XSS) A8: Insecure DeserializationA9: Using Components with Known Vulnerabilities A10: Insufficient Logging and Monitoring

Page 9: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Serverless Risks - CSASAS-1: Function Event Data InjectionSAS-2: Broken AuthenticationSAS-3: Insecure Serverless Deployment ConfigurationSAS-4: Over-Privileged Function Permissions & RolesSAS-5: Inadequate Function Monitoring and LoggingSAS-6: Insecure Third-Party DependenciesSAS-7: Insecure Application Secrets StorageSAS-8: Denial of Service & Financial Resource ExhaustionSAS-9: Serverless Business Logic ManipulationSAS-10: Improper Exception Handling and Verbose Error MessagesSAS-11: Obsolete Functions, Cloud Resources and Event TriggersSAS-12: Cross-Execution Data Persistency

Page 10: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Serverless Risk Categorization

Application Code & App Logic Risks

DeploymentConfigurations Risks

Serverless Platform Risks

Misc.Risks

InjectionBroken AuthenticationSensitive data exposureInsecure deserializationKnown vulnerabilitiesImproper exception handling

Security misconfigurationOverprivileged permissionInsecure secrets storage

Broken access controlInadequate Monitoring

DoSUnused functionsData PersistencyXSS, XXE

Page 11: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

A1: Injection

Page 12: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Injection

Page 13: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Injection● Use Web Application Firewall● Validate data based on schemas and data transfer objects● Always use an ORM● Escape special characters● Use least privileges● Consider all event types and entry points into the system● Use a commercial runtime defense solution

Page 14: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

A2: Broken Authentication

Page 15: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Broken Authentication● AWS Cognito or Single Sign-On● API Gateway Access control

○ API keys○ Usage plans○ AWS IAM roles and policies○ Amazon Cognito user pools○ Lambda authorizer functions

● Service authentication between internal resources○ SAML, OAuth2, Security Tokens○ Encrypted channels○ Password and key management○ Client certificate○ OTA/2FA

Page 16: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

A3: Sensitive Data Exposure

Page 17: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Sensitive Data Exposure● Identify and classify sensitive data● Minimize storage of sensitive data● Protect data at rest and in transit● Use HTTPS only endpoints for APIs● Key management● Encryption of stored data● Secret Management● Environment variables encryption

Page 18: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

A5: Broken Access Control

Page 19: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Broken Access ControlFine grained access control

POST

GET

DELETE

customers table

orders table

queue

Amazon API Gateway

Page 20: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Broken Access ControlFollow least-privilege

Page 21: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Broken Access ControlAutomate permission configuration

Page 22: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Broken Access ControlAutomate permission configuration

Page 23: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Broken Access ControlAutomate security testing of IaC

CloudFormation CloudWatch Lambda

Event for stack CREATE/UPDATE

Pull CF Script from S3

S3

Notify on failure

SES

CF Script

Page 24: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Broken Access ControlAnalyze IAM access patterns programmatically

Page 25: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Broken Access ControlAnalyze IAM access patterns programmatically

Page 26: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Broken Access ControlFollow AWS IAM Best Practices

Page 27: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

A7: Security Misconfiguration

Page 28: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Security Misconfiguration● Enforce access control● Providers security best practices● Check for functions with unlinked triggers ● Resources that appear in policies but are not linked back to the function● Set timeouts to the minimum required by the function● Use automatic tools that detect security misconfigurations

Page 29: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

A7: Known Vulnerabilities

Page 30: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Known Vulnerabilities● Continuously monitor dependencies and their versions ● Only obtain components from official sources ● Continuously monitor sources like CVE and NVD ● Platform based advisories like NodeSecurity, PyUp, OWASP SafeNuGet, etc.● Scan dependencies for known vulnerabilities

○ OWASP Dependency Check○ GitHub Security Alerts○ Gitlab Dependency Scanning○ WhiteSource

Page 31: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Serverless Security Demo

Page 32: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Serverless Security Demo1. Information Gathering2. Function Reverse Engineering3. Digging For Gold Inside Environment Variables4. Exploiting Over-Privileged IAM Roles5. Abusing Insecure Cloud Configurations6. Finding Known Vulnerabilities In Open Source Packages

Page 33: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Security for Amazon Kubernetes Cluster

Page 34: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Encrypt communication● Between web clients and your loadbalancer

○ Use the application loadbalancer (ALB)○ Can be achieved with the ALB-Ingress-Controller○ ALB provides routing and security options for the application layer

● Between your loadbalancer and pod○ Encryptions support of your application or application server○ Run a sidecar on your pod which performs encryption○ Run a complete service mesh like Istio

● Between your pod and your AWS RDS database

Page 35: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Encrypt storage● Databases● Persistent Volume Claims (PVC)

Page 36: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Restrict inbound and outbound traffic● Use network policies ● Network Policy engine (Calico)

Page 37: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

More EKS Security Tips● Use a firewall to block known web attacks● Protect yourself from DDos attacks● Secure your AWS account● Use namespaces and secrets● Cyber attack detection● Review your security setup● Scan your container images

○ Aqua Security Microscanner○ CoresOS Clair○ Anchore engine

Page 38: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Container DevSecOps

Page 39: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Developer

AWS Cloud9

1.Pull Request

AWS CodeCommit(Application Repo)

AWS Lambda Function

Amazon CloudWatch Event Rule

7. Adds feedback to Pull Request

6. Triggers Lambda Function

5. CodeBuild Success/Failure triggers Rule

AWS CodePipeline

AWS CodeBuild AWS CodeBuild AWS CodeBuild AWS CodeBuild

DOCKER LINTING PUBLISH IMAGEVULNERABILITY SCANNINGSECRETS SCANNING

Configs

Development

PULL REQUEST

AWS Security Hub Amazon ECR

3. Pushes vulnerabilities to Security Hub

4. Builds and pushes Image to ECR

2. Triggers CodePipeline

Page 40: Securing Serverless and Container Services...Securing Serverless and Container Services Marc Schröter AWS DevOps Engineer @ globaldatanet Community Day 2019 Sponsors DevOps Automation

Build with services not serversAhhhh and we are hiring

globaldatanet

globaldatanet globaldatanet.com

[email protected]