SLIDE 1 Securing Serverless and Container Services
Marc Schröter AWS DevOps Engineer @ globaldatanet
Community Day 2019 Sponsors
SLIDE 2 DevOps Automation Continuous Delivery Infrastructure as Code Cloud Security Security and Compliance Controls Container Managing the full container life cycle Serverless Highly scalable and fault-tolerant solutions
SLIDE 3
What is serverless, and how does it impact your approach to security?
SLIDE 4
What is serverless?
Shift operational responsibilities to AWS Increasing your agility and innovation
SLIDE 5 No infrastructure provisioning, no management Automatic scaling Pay for value Highly available and secure
SLIDE 6 COMPUTE INTEGRATION DATA STORES
AWS Lambda AWS Fargate Amazon S3 Amazon Aurora Serverless AWS DynamoDB Amazon API Gateway Amazon SQS Amazon SNS Amazon Step Functions
SLIDE 7
SLIDE 8
Serverless Risks - OWASP
A1: Injection A2: Broken Authentication A3: Sensitive Data Exposure A4: XML External Entities (XXE) A5: Broken Access Control A6: Security Misconfiguration A7: Cross-Site Scripting (XSS) A8: Insecure Deserialization A9: Using Components with Known Vulnerabilities A10: Insufficient Logging and Monitoring
SLIDE 9
Serverless Risks - CSA
SAS-1: Function Event Data Injection SAS-2: Broken Authentication SAS-3: Insecure Serverless Deployment Configuration SAS-4: Over-Privileged Function Permissions & Roles SAS-5: Inadequate Function Monitoring and Logging SAS-6: Insecure Third-Party Dependencies SAS-7: Insecure Application Secrets Storage SAS-8: Denial of Service & Financial Resource Exhaustion SAS-9: Serverless Business Logic Manipulation SAS-10: Improper Exception Handling and Verbose Error Messages SAS-11: Obsolete Functions, Cloud Resources and Event Triggers SAS-12: Cross-Execution Data Persistency
SLIDE 10 Serverless Risk Categorization
Application Code & App Logic Risks Deployment Configurations Risks Serverless Platform Risks Misc.Risks
Injection Broken Authentication Sensitive data exposure Insecure deserialization Known vulnerabilities Improper exception handling Security misconfiguration Overprivileged permission Insecure secrets storage Broken access control Inadequate Monitoring DoS Unused functions Data Persistency XSS, XXE
SLIDE 11
A1: Injection
SLIDE 12
Injection
SLIDE 13 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
SLIDE 14
A2: Broken Authentication
SLIDE 15 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
SLIDE 16
A3: Sensitive Data Exposure
SLIDE 17 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
SLIDE 18
A5: Broken Access Control
SLIDE 19 Broken Access Control
Fine grained access control
POST GET DELETE customers table
queue Amazon API Gateway
SLIDE 20
Broken Access Control
Follow least-privilege
SLIDE 21
Broken Access Control
Automate permission configuration
SLIDE 22
Broken Access Control
Automate permission configuration
SLIDE 23 Broken Access Control
Automate security testing of IaC
CloudFormation CloudWatch Lambda Event for stack CREATE/UPDATE Pull CF Script from S3 S3 Notify on failure SES CF Script
SLIDE 24
Broken Access Control
Analyze IAM access patterns programmatically
SLIDE 25
Broken Access Control
Analyze IAM access patterns programmatically
SLIDE 26
Broken Access Control
Follow AWS IAM Best Practices
SLIDE 27
A7: Security Misconfiguration
SLIDE 28 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
SLIDE 29
A7: Known Vulnerabilities
SLIDE 30 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
SLIDE 31
Serverless Security Demo
SLIDE 32
Serverless Security Demo
1. Information Gathering 2. Function Reverse Engineering 3. Digging For Gold Inside Environment Variables 4. Exploiting Over-Privileged IAM Roles 5. Abusing Insecure Cloud Configurations 6. Finding Known Vulnerabilities In Open Source Packages
SLIDE 33
Security for Amazon Kubernetes Cluster
SLIDE 34 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
SLIDE 35 Encrypt storage
- Databases
- Persistent Volume Claims (PVC)
SLIDE 36 Restrict inbound and outbound traffic
- Use network policies
- Network Policy engine (Calico)
SLIDE 37 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
SLIDE 38
Container DevSecOps
SLIDE 39 Developer AWS Cloud9 1.Pull Request AWS CodeCommit (Application Repo) AWS Lambda Function Amazon CloudWatch Event Rule
Pull Request
Function
- 5. CodeBuild Success/Failure
triggers Rule AWS CodePipeline AWS CodeBuild AWS CodeBuild AWS CodeBuild AWS CodeBuild DOCKER LINTING PUBLISH IMAGE VULNERABILITY SCANNING SECRETS SCANNING Configs Development PULL REQUEST AWS Security Hub Amazon ECR
- 3. Pushes vulnerabilities
to Security Hub
Image to ECR
CodePipeline
SLIDE 40 Build with services not servers
Ahhhh and we are hiring globaldatanet globaldatanet globaldatanet.com mail@globaldatanet.com