Part 1
- Threat Intelligence Report
- Types of attack
- Zero Day exploit
- Cross Site scripting
- SQL injection
- Remote code execution
- Cross-Site Request Forgery
- Explain how a vulnerability exploited can provide access to the network
- A vulnerability allows the attack to execute code on server, that code can be used to spawn shells or gain privileges
- Preventative measures
- Regular/Automated patching
- Vulnerability scanning
- Use threat intelligence feeds
- WAF
- Pen-testing
- Types of attack
- Incident Reponse Plan
- Identify the affected web server and block inbound/outbound traffic
- Take a snapshot of the EBS volumes
- Scan for malware/vulnerabilities
- Review Cloudwatch logs for affected EC2 instance, identify what IP addresses it was communicating with (apart from “normal” or expected traffic); block those IP addresses as necessary
- Terminate affected web server
- Restore web server from last known good backup / AMI image
- Patch new web server to prevent attackers from regaining access
- Monitor new web server for unusual activity
- Send communications out to necessary parties about incident
- Test new web server
- Network Security Measures
- Implement AWS GuardDuty & integrate w/ SecurityHub for Intrusion Detection / Intrusion Prevention
- Implement AWS Web Application Firewall (WAF)
- Network segmentation: use private subnets for all EC2 instances and RDS instances. Web servers can use ELB’s in front for their public IP’s. Create security groups with a deny-all and least privilege the necessary ports and CIDR’s.
Part 2
- Docker Security Best Practices
- 5 best practices:
- Use trusted / official images for containers
- Run containers as non-root user
- Enable Content Trust
- Scan images for vulnerabilities
- Minimize image size
- Dockerfile code: (I’m familiar with docker-compose, so I’ll use that)
- 5 best practices:
version: '3.8'
services:
web:
image: httpd:alpine # 1. Use Official/Base Images
ports:
- "80:80"
- “443:443”
volumes:
- app-data:/app/data:ro # Mount as read-only
user: "1000:1000" # Run as non-root user
depends_on:
- postgres
security_opt:
- no-new-privileges:true #prevent container from gaining additional privileges
environment:
- PUID=${PUID} # default user id, defined in .env
- PGID=${PGID} # default group id, defined in .env
- TZ=${TZ} # timezone, defined in .env
postgres:
image: postgres:alpine # Use official, minimized Alpine-based image
user: "1001:1001" # Run as non-root user
ports:
- "5432:5432"
volumes:
- ${ROOT}/pg/data:/config
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
security_opt:
- no-new-privileges:true #prevent container from gaining additional privileges
environment:
- PUID=${PUID} # default user id, defined in .env
- PGID=${PGID} # default group id, defined in .env
- TZ=${TZ} # timezone, defined in .env
- Kubernetes Security Configuration
- Pod Security Admission – enforce rules like disallowing privileged containers
- Network Policies – define ingress/egress rules to control traffic between pods
- RBAC – limits user and service account permissions to only necessary resources
- YAML:
apiVersion: v1
kind: Pod
metadata:
name: secure-pod
spec:
containers:
- name: app-container
image: nginx:latest
securityContext:
runAsUser: 1001 # Non-root user
runAsGroup: 1001
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL # Drop all capabilities
readOnlyRootFilesystem: true # Mount root FS as read-only
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}
- IaaS Security Measures
- IaaS is a shared responsibility model where the provider manages the hardware and the user handles the software (operating system, applications, data). The user is responsible for securing their operating systems and applications. The provider is responsible for securing their hardware (physical access)
Part 3
- Terraform & Ansible playbook to automate the deployment of a web server on an EC2 instance:
The terraform creates the EC2 instance, waits for it to be online and available, then executes the Ansible playbook against the newly created EC2 instance to configure the web server as needed
INSTRUCTIONS
- Clone repo
- Modify files as neccessary
- Initialize terraform
$ terraform init
- Create plan
$ terraform plan
- Apply
$ terraform apply