Cloud Security
Cloud security fails less often through novel attacks than through configuration. Storage buckets left public, over-broad identity policies, security groups that opened a database to the world, disabled logging â these are the incidents that dominate public breach reports, and every one of them is a customer-side decision. This lesson builds a mental model for where responsibility sits, then works through identity, network and detection controls in a way that transfers across AWS, Azure and GCP.
Who is actually responsible
The shared responsibility model splits duties between provider and customer, and the split moves with the service model. In infrastructure-as-a-virtual-machine, the provider runs the hypervisor, physical network and data centers while you own the guest operating system, patching, identity and data. In platform-as-a-service, the provider also runs the OS and runtime, and your surface shrinks to application code, configuration and data. In software-as-a-service, you own identities, access grants and the data you put in.
| Layer | IaaS | PaaS | SaaS |
|---|---|---|---|
| Physical hardware and data centers | Provider | Provider | Provider |
| Hypervisor and host network | Provider | Provider | Provider |
| Operating system and patching | Customer | Provider | Provider |
| Runtime and middleware | Customer | Provider | Provider |
| Network configuration and firewall rules | Customer | Customer | Provider |
| Identity, access, data classification | Customer | Customer | Customer |
Two recurring failures come from this table. Customers under-patch IaaS guests because "it is in the cloud", and customers assume SaaS data is protected when in fact the provider guarantees the platform's availability and encryption while your sharing settings decide who can read the file. When something goes wrong, the first question is always which row of the table you were standing on.
Identity is the new perimeter
With perimeters dissolved into APIs, every cloud interaction is an identity decision. Start with a root or owner account that no human uses for daily work, protected by hardware-backed multi-factor authentication and used only for break-glass tasks. Humans get individual identities with SSO and MFA; workloads get short-lived roles assumed through a provider-native mechanism rather than static access keys, which leak into repositories with depressing regularity.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadOnlyObjectsInOnePrefix",
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": [
"arn:aws:s3:::reports-prod",
"arn:aws:s3:::reports-prod/quarterly/*"
]
},
{
"Sid": "DenyEverythingElse",
"Effect": "Deny",
"Action": "s3:*",
"Resource": "*",
"Condition": {
"StringNotLike": {
"aws:PrincipalTag/team": "finance-reporting"
}
}
}
]
}
Read that policy as a set of habits. The Resource is a single prefix rather than the whole bucket; a Deny statement closes the door against a later broad Allow added by someone in a hurry; and an explicit condition means the policy fails closed when the expected tag is missing. The equivalent discipline on Azure uses role assignments scoped to a resource group rather than the subscription, and on GCP uses deny policies and service accounts bound to specific workloads.
Practical hygiene follows directly: audit unused roles quarterly, remove long-lived keys in favor of short-lived credentials, apply permissions boundaries so a role can never exceed a ceiling, and log every privilege change. Cloud infrastructure is version-controlled; treat policy files as code with review, tests and drift detection, because a console change made at midnight is a change nobody reviewed.
Network controls in a programmable fabric
Cloud networks are software, which makes them both easier to secure and easier to undo. Virtual private clouds start isolated by default; exposure happens when routes, gateways and security groups are added. Stateful security groups are the workhorse â allow inbound on 443 from the load balancer only, allow the database port only from the application subnet, deny everything else, and never let a database face the internet as a "temporary" measure.
# AWS: an ingress rule scoped to a specific security group, not the whole internet
aws ec2 authorize-security-group-ingress \
--group-id sg-0a1b2c3d \
--protocol tcp --port 443 \
--source-group sg-0feedbee # only the load-balancer group may reach the app
# Azure: an NSG rule limited to one subnet's address prefix
az network nsg rule create \
--nsg-name appNsg --resource-group prod-rg \
--name AllowAppToDb --priority 200 \
--protocol Tcp --destination-port-ranges 5432 \
--source-address-prefixes 10.0.20.0/24 --access Allow
# GCP: internal-only firewall rule with no external range at all
gcloud compute firewall-rules create allow-internal-db \
--network app-vpc --direction INGRESS --action ALLOW \
--rules tcp:5432 --source-ranges 10.0.30.0/24 --target-tags db-node
# Everywhere: find what is accidentally public
aws ec2 describe-security-groups --query 'SecurityGroups[?contains(IpPermissions[].CidrIp, `0.0.0.0/0`)]'
Beyond the virtual network perimeter: put managed databases in private subnets with no public IP; use a centralized egress path so outbound traffic can be filtered (which stops a compromised workload from calling a command-and-control server); and never expose a cloud metadata service without the provider's hardening options enabled, because those endpoints hand out temporary credentials to anything that can reach them.
Misconfiguration and the drift problem
Environments drift the moment humans get console access. A security group gets 0.0.0.0/0 for a demo and stays that way; a bucket's block-public-access setting is turned off for an upload test; a log bucket's lifecycle policy deletes everything after seven days. The defense is continuous evaluation rather than periodic review: codify the baseline, scan every deployment, and alert on drift in near real time.
# Baseline checks as code â run on every plan and nightly against production
aws configservice describe-config-rules --query 'ConfigRules[].ConfigRuleName'
# Continuous posture assessment, with findings routed to the security backlog
aws securityhub batch-import-findings --findings file://findings.json
aws accessanalyzer validate-policy --policy-document file://policy.json --policy-type IDENTITY_POLICY
# Prove encryption and logging are actually on, not just requested at creation
aws s3api get-bucket-encryption --bucket reports-prod
aws s3api get-bucket-logging --bucket reports-prod
aws cloudtrail describe-trails --query 'trailList[?IsMultiRegionTrail==`true`]'
Automate the response too: a public bucket can be auto-quarantined, an untagged resource can be auto-stopped in non-production, and an alarm on root-account usage should page someone immediately. Guardrails remove the need for every engineer to remember every rule.
Logging, detection and the evidence you will need
A cloud account without centralized logging is a system you cannot investigate. Turn on control-plane logging (API activity, console sign-ins, permission changes), forward it to an account separate from the one being monitored so a compromised admin cannot cover their tracks, and enable the provider's threat-detection service for the signals it correlates better than you can.
| Log source | What it tells you | Alert on |
|---|---|---|
| Control-plane / API log | Who changed what, when | Security group opened to the world, log stopped, MFA disabled |
| Identity logs | Sign-ins and failures | Root login, impossible travel, new access key |
| Network flow logs | Who talked to whom | Egress to unusual regions or rare destinations |
| Data-plane logs | Object and record access | Bulk download, sensitive bucket listing |
| Endpoint / workload logs | Process and file behavior | Shell spawned by a runtime, child process anomalies |
Retain long enough to reconstruct an incident: weeks is rarely enough when breaches are discovered months later. Record retention is a legal requirement in several industries, so tie the retention policy to obligations rather than to storage cost alone.
A practical baseline for any new cloud account
Before the first workload ships: enable organization-wide guardrails (service control policies or their equivalents), enforce MFA and SSO for humans, require short-lived credentials for workloads, enable all control-plane logging into a separate security account, enable the native threat-detection service, apply an encryption-by-default policy for storage and databases, restrict regions and instance types to what the business actually uses, and run a posture scan to see where you already stand.
Then keep the loop tight: findings enter the same backlog as engineering work, with owners and due dates, and recurring classes of misconfiguration get automated guardrails instead of repeated tickets. Cloud security is not a product you buy; it is a set of defaults you refuse to let anyone weaken.
Common Mistakes
Assuming the provider protects your data in SaaS and PaaS
Fix: Map each layer of the shared responsibility table and assign a named owner for every customer-side row.
Creating long-lived static access keys for humans and scripts
Fix: Use SSO with MFA for people and short-lived role assumption for workloads; rotate and audit anything static that remains.
Scoping IAM policies to Resource wildcard for convenience
Fix: Limit resources to specific buckets, prefixes and regions, and add explicit Deny statements for ceilings.
Running a one-time security review after migration
Fix: Scan continuously for drift and auto-remediate the classes of misconfiguration that recur.
Sending logs to the account or subscription being monitored
Fix: Forward control-plane logs to a separate security account so a compromised administrator cannot erase them.
Best Practices
- Treat infrastructure and policy as code with review, tests and drift detection.
- Keep the root or owner account unused for daily work and protected by hardware MFA.
- Place databases in private subnets and route egress through a filtering path.
- Enable encryption by default at the organization level, not per resource.
- Measure posture continuously: public assets, unencrypted stores, stale keys, dormant roles.
Key Takeaways
- Shared responsibility shifts by service model â know which row of the table you stand on before assigning blame or controls.
- Cloud breaches are dominated by identity and configuration failures, not by broken cryptography.
- Scope policies to resources, fail closed with explicit Deny rules, and prefer short-lived credentials over static keys.
- Network isolation, private data stores and filtered egress remove entire attack paths by default.
- Centralized, tamper-resistant logging is what makes investigation possible after a cloud incident.
- Continuous evaluation beats periodic review because console changes create drift nobody remembers.