Sub topic 5
Worked examples: EC2, RDS, and S3
This chapter applies the shared responsibility model to three services. It assumes you can read a short AWS CLI command and know what a security group, an IAM role, and a bucket policy are. It also assumes you know the earlier chapters' split between security of the cloud and security in the cloud, and the three service categories (infrastructure, container, abstracted).
The three services sit at different points on the spectrum. EC2 is an infrastructure service, so you manage a lot. RDS is a container-style managed service, so AWS takes over the host and the database software install, and you keep the data and access. S3 is closest to abstracted: you never see a server, but you still decide who can read each object.
How to run the analysis
For each service, ask the same four questions:
- Which layers can I not touch at all? Those are AWS's.
- Which layers can I touch, and does AWS patch or rotate them for me?
- Which settings have a default I did not choose?
- Where does my data live, and who can reach it?
The answers below follow that order.
Example 1: Amazon EC2
EC2 gives you a virtual machine. AWS secures everything beneath the guest operating system. You secure everything from the guest operating system upward.
What AWS owns
- Data center physical security and power.
- Host hardware and firmware.
- The virtualization layer (the Nitro hypervisor), including isolation between instances on the same host.
- The network fabric between hosts, and the availability of the Regions and Availability Zones.
What you own
- The guest operating system: patches, hardening, local users, and host firewall rules.
- Software you install, and the AMI you launch from. A public AMI is not vetted for your workload.
- The security groups and network ACLs that control traffic to the instance.
- The IAM role attached to the instance, which defines what credentials code on the machine receives.
- Whether EBS volumes are encrypted, and who may use the KMS key.
- Backups and snapshots, and their sharing permissions.
- Agent software such as the Systems Manager agent or logging agents.
A concrete failure mode
An unpatched web server on EC2 is not an AWS failure. AWS patched the hypervisor and hardware, and you left the guest operating system exposed. This is the clearest case of customer-owned patching.
Two settings worth checking
The instance metadata service hands temporary role credentials to software on the instance. Version 1 of that service can be abused by server-side request forgery bugs in your applications. Version 2 requires a session token. You choose which to allow, and you can require version 2 on an existing instance:
aws ec2 modify-instance-metadata-options \
--instance-id i-0123456789abcdef0 \
--http-tokens required \
--http-endpoint enabledFor disks, you can make new EBS volumes in a Region encrypted by default. This is a Regional setting, so repeat it in every Region you use:
aws ec2 enable-ebs-encryption-by-default --region us-east-1
aws ec2 get-ebs-encryption-by-default --region us-east-1AWS supplies the encryption and the key infrastructure. The decision to use them is yours.
Example 2: Amazon RDS
RDS runs a relational database engine such as PostgreSQL or MySQL on instances that AWS manages. The responsibility line moves up because AWS now owns more layers.
What AWS owns
- Everything it owns for EC2.
- The operating system of the underlying host. You cannot log in to it.
- Installing and operating the database software, and applying the patches it releases for the managed platform.
- The automation for backups, Multi-AZ failover, and replacement of failed hardware, once you enable them.
What you own
- Network access: the security groups on the instance, the subnet group it uses, and the
PubliclyAccessiblesetting. - Database accounts, passwords or IAM database authentication, and the permissions inside the database (grants, roles, row-level rules).
- Encryption at rest. You choose it, and you must choose it when you create the instance. You cannot switch encryption on for an existing unencrypted instance. You instead copy a snapshot with encryption enabled and restore from the copy.
- Encryption in transit. RDS offers TLS endpoints, but you decide whether clients must use TLS (for example through a parameter group setting such as
rds.force_sslon PostgreSQL) and whether your application verifies the certificate. - Backup retention period, snapshot sharing, and deletion protection.
- Choosing the maintenance window and whether minor engine version upgrades happen automatically.
The shared part: patching
Patching in RDS is shared. AWS prepares and delivers the updates and applies them during the window. You decide the window, whether minor upgrades are automatic, and when to move to a new major version. A database left on an engine version past its end of support is a customer decision, even though no one logged in to the host.
Checking your side
This query lists the settings that most often drift from intent:
aws rds describe-db-instances \
--query 'DBInstances[].{id:DBInstanceIdentifier,encrypted:StorageEncrypted,public:PubliclyAccessible,multiAz:MultiAZ,backupDays:BackupRetentionPeriod,autoMinor:AutoMinorVersionUpgrade}' \
--output tableA row with public set to True and a security group open to 0.0.0.0/0 is a customer misconfiguration. RDS did exactly what it was told.
Example 3: Amazon S3
S3 is an object store. You never manage servers, storage hardware, or an operating system. The AWS side is large, and the customer side is short but consequential.
What AWS owns
- Durability and availability of the storage system, including replication of objects across facilities.
- Hardware, software, and physical security of the service.
- The encryption machinery. Since January 2023, S3 applies server-side encryption with S3-managed keys (SSE-S3) to all new objects by default.
What you own
- Who can access each bucket and object: bucket policies, IAM policies, access points, and ACLs.
- Whether a bucket can be made public. Block Public Access is the main guardrail.
- Which encryption type you use, such as SSE-KMS with your own key, and who can use that key.
- Whether versioning, MFA delete, or Object Lock protect against deletion and overwrites.
- Access logging and CloudTrail data events, so you can see who read what.
- Data classification: deciding which data belongs in which bucket.
- Lifecycle rules and cross-Region replication, if your recovery targets require them.
A note on defaults
New buckets have Block Public Access on and ACLs disabled by default. Those defaults help, but defaults can be changed by anyone with enough permission. Setting the controls explicitly, and checking them, is what makes them your control. This command turns on all four Block Public Access settings for one bucket:
aws s3api put-public-access-block \
--bucket amzn-s3-demo-bucket \
--public-access-block-configuration \
BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=trueTo protect against accidental overwrites and deletes, enable versioning:
aws s3api put-bucket-versioning \
--bucket amzn-s3-demo-bucket \
--versioning-configuration Status=EnabledSide-by-side comparison
| Control area | EC2 | RDS | S3 |
|---|---|---|---|
| Physical and hypervisor | AWS | AWS | AWS |
| Host operating system | Customer (guest OS) | AWS | AWS |
| Database or application software | Customer | AWS installs and patches the platform, customer picks versions and windows | Not applicable |
| Network access | Customer (security groups, NACLs) | Customer (security groups, public flag) | Customer (policies, Block Public Access) |
| Identity and permissions | Customer (instance role, OS users) | Customer (database users, IAM auth) | Customer (IAM, bucket policy) |
| Encryption at rest | Customer chooses for EBS | Customer chooses at creation | AWS default SSE-S3, customer chooses stronger options |
| Backup and recovery | Customer (snapshots, AMIs) | Shared (AWS runs it, customer sets retention) | Customer (versioning, replication) |
What stays the same
Two points hold across all three services:
- Identity and data are always yours. Even on the most abstracted service, you decide who may call the API and what the data is worth.
- The more AWS manages, the fewer settings you have, but each remaining setting carries more weight. An RDS instance has no operating system for you to patch, so its network exposure and database permissions are most of what an attacker can reach.
Common mistakes in these examples
- Assuming a managed service is secure by default. RDS accepts a public endpoint if you ask for one.
- Treating encryption as retroactive. RDS encryption must be set at creation, and EBS default encryption only covers new volumes.
- Confusing availability with protection. Multi-AZ RDS and replicated S3 storage survive hardware failure. They do not survive a
DROP TABLEor a delete command. - Forgetting Regional scope. EBS default encryption is per Region.
Check your side with AWS Config
You can list which AWS Config rules currently report non-compliant resources. This is one way to confirm that your side of the model is configured as intended:
aws configservice describe-compliance-by-config-rule \
--compliance-types NON_COMPLIANTManaged rules exist for the exact issues above, including unencrypted EBS volumes, publicly accessible RDS instances, and S3 buckets without public access blocks. The chapter on verification covers these in detail.
Exercise
A team runs a PostgreSQL database on RDS with PubliclyAccessible set to true and a security group allowing port 5432 from 0.0.0.0/0. An attacker guesses a weak database password and reads customer data. Who is responsible, which two settings should have been different, and why can the team not fix storage encryption on this instance by editing a setting?
Show answer
The customer is responsible. AWS operated the host and engine as designed, while the customer controlled network exposure and database credentials. The PubliclyAccessible flag should have been false, and the security group should have allowed only the application's security group or a known CIDR range. Strong credentials or IAM database authentication should have been used as well. Storage encryption cannot be turned on for an existing unencrypted RDS instance. The team must copy a snapshot with encryption enabled and restore a new instance from that copy.
Exercise
You run a web application on EC2. Name three things AWS handles and three things you handle, and say which of your three would be the likely cause if an attacker steals role credentials through a bug in your application's URL-fetching feature.
Show answer
AWS handles the physical data center, the host hardware, and the hypervisor. You handle guest OS patching, security groups, and the instance's IAM role. In the stolen-credentials case, the likely cause is the instance metadata service allowing version 1 requests. Requiring IMDSv2 with --http-tokens required and limiting the IAM role's permissions would reduce the damage. Both are customer-side controls.