PRACTITIONERCHAPTER 09

Cloud and infrastructure security

Most cloud breaches are configuration, not exploits: audit an account the way an attacker reads it, rank findings by path to data, and turn fixes into guardrails

45 MINSECURITYUPDATED 2026-11-05
PREDICT

You run a benchmark scan on a payments company's production AWS account. It reports 1,214 failed checks, 31 of them rated critical. You have one week of engineering time from the platform team. What do you fix first?

A cloud security engineer owns one question: could someone who should not, reach something that matters, through the way this estate is configured? The estate is the cloud accounts, the clusters, the CI system that deploys into them, and the identities that hold the keys. The answer is almost never found in a vulnerability database. It is in policies, network rules and settings that someone set for a good reason on a busy day.

This chapter is about the core practitioner artefact for that job: a misconfiguration audit that ranks what it finds by how an attacker would use it, and ends in guardrails rather than a spreadsheet. It also covers the moment an audit turns into an incident, because the most common serious finding, storage open to the internet, is also the one most likely to be a reportable breach.

The shared-responsibility line

Every cloud provider publishes a version of the same split. AWS calls it security of the cloud versus security in the cloud: the provider secures the hardware, the hypervisor, the network and the managed services; you secure everything you configure on top. For a virtual machine that includes the guest operating system. For a storage bucket it is the data, its classification, the bucket policy, the identity policies that can reach it, and whether access is logged.

The line moves with the service. The more managed the service, the less you patch and the more of your exposure lives in configuration. A serverless function has no operating system for you to harden, but its execution role can still read every table in the account. This is why cloud security work looks less like patching and more like reviewing policy: identity and resource policies are the attack surface.

Three things follow. First, the provider’s certifications do not cover your configuration; a SOC 2 report for the provider says nothing about your bucket policy. Second, your controls are code and can be reviewed like code. Third, the provider gives you strong tools to see and constrain your configuration, and most breaches happen in accounts where those tools were available and not turned on.

How accounts are actually lost

Before you audit, know what you are looking for. The recurring patterns in public breach reports and court filings are few.

Storage open to the world. A bucket policy with "Principal": "*", or an object ACL granting the AllUsers group, on a bucket someone made public for a demo, a partner export, or a static site. Search engines for open buckets exist; assume, as a rule of thumb, that discovery is a matter of days, not months.

Long-lived credentials that leak. Access keys for an IAM user, committed to a repository, baked into a container image, pasted into a ticket, or left with a contractor who has gone. The secrets rotation lesson covers why a leaked key stays dangerous until it is revoked, not until it is noticed.

A reachable workload with a powerful role. The Capital One pattern. Something exposed to the internet, a proxy, a firewall, an application with a server-side request forgery bug, can be made to fetch the credentials of the role attached to it. The complaint itself says only that a firewall misconfiguration let commands reach the server and that the first command obtained the role’s credentials; most public analyses describe it as server-side request forgery against the EC2 instance metadata service. In November 2019 AWS published IMDSv2, which requires a session token obtained with a PUT request and rejects requests carrying an X-Forwarded-For header, as defence against exactly the open firewalls, reverse proxies and SSRF bugs that make this work. Whatever the entry point, the damage was set by what the role could read.

Management planes on the internet. A database with a public endpoint, a Kubernetes API server open to 0.0.0.0/0, an admin dashboard with no authentication because it was meant to be internal.

No record of what happened. Logging off in a region, data-access logging never enabled on the bucket that mattered, logs kept for seven days. This does not cause the breach. It decides whether you can say what the breach was, which matters a great deal once a regulator asks.

The model: four planes and an attacker’s path

Read an account as four planes, and then as paths across them.

Plane The question Where it lives on AWS
Identity Who and what can act, and with which permissions? IAM users, roles, policies, permission boundaries, SCPs, identity provider federation
Network What can reach what, from where? Security groups, network ACLs, route tables, load balancers, public endpoints
Data Where is the sensitive data, and who can read it? Bucket and key policies, database endpoints, snapshots, encryption settings
Evidence Would you know, and could you prove it? CloudTrail (management and data events), access logs, GuardDuty, retention

A finding sits in one plane. An attack path crosses them: an internet-facing instance (network) with IMDSv1 allowed and a role holding s3:GetObject on * (identity) in an account with a bucket of loan applications (data) and no data-event logging (evidence). Each of those is a “medium” in most tools. Together they are the Capital One shape.

This is the threat model from threat modelling applied to infrastructure. The entry points are the internet edge, leaked credentials and the CI pipeline. The assets are the data stores and the identity system itself, because whoever controls IAM controls everything else.

The standards you audit against

You do not invent the checklist. Three sources do most of the work, and they do different jobs.

The AWS Well-Architected Framework security pillar is the reasoning. Its seven design principles are: implement a strong identity foundation, maintain traceability, apply security at all layers, automate security best practices, protect data in transit and at rest, keep people away from data, and prepare for security events. It organises practice into seven areas: security foundations, identity and access management, detection, infrastructure protection, data protection, incident response and application security. Use it to explain why a finding matters to an engineer who thinks it is pedantry.

The CIS Benchmarks are the checklist. The Center for Internet Security publishes consensus-built configuration benchmarks for each major cloud (the CIS AWS, Azure and Google Cloud Foundations Benchmarks), for Kubernetes and the managed Kubernetes services, and for operating systems. Recommendations are grouped into Level 1 profiles, which are practical for most organisations, and Level 2, which trade convenience for depth. Benchmarks are versioned and recommendation numbers change between versions, so always write the version in your audit and cite recommendations by number and version together. The PDFs are free for non-commercial use from cisecurity.org.

The tools run the checklist. AWS Security Hub runs the CIS AWS Foundations Benchmark and AWS’s own Foundational Security Best Practices as standards across accounts. IAM Access Analyzer reports resources shared outside your account or organisation, which is the fastest way to find public buckets and cross-account trust. Open-source scanners such as Prowler run the same benchmarks across several clouds from your laptop. The equivalent on Azure is Defender for Cloud, and on Google Cloud the Security Command Center.

Tools are where audits go wrong. A scanner produces a long list sorted by its own severity. It does not know which bucket holds passports and which holds build logs, or that the role it flagged is attached to the only internet-facing instance. Your audit adds that context, and that context is the job.

Running the audit

A misconfiguration audit of one account, or one organisation, takes a practitioner two to five days the first time, as a rule of thumb. The steps:

  1. Scope and inventory. List every account, every region in use, and every region not in use (attackers like those). Get read-only access through a role, not a user. Write down what you did not cover.
  2. Find the data. Before running any scanner, ask the owning team where the sensitive data lives: customer records, documents, card data, credentials. Tag the stores. A finding near this data is worth ten elsewhere.
  3. Find the edge. List everything reachable from the internet: load balancers, public IPs, API gateways, public buckets, public snapshots, database endpoints.
  4. Run the benchmark. Security Hub or Prowler against the CIS benchmark at a stated version, plus IAM Access Analyzer. Export the results.
  5. Trace paths. For each internet-facing workload, follow its role to what it can read and write. For each long-lived key, ask who holds it and what it reaches. These traces are your top findings.
  6. Rank and assign. Each finding gets exposure, data sensitivity, exploitability, a severity you set yourself, a named owner and a date. Then sort the fixes into three piles: fix now, prevent with a guardrail, and accept with a written reason and an expiry.

Two checks to make by hand, because tools under-report them: role trust policies that allow assumption from other accounts or from a CI provider with a broad condition, and resource policies on KMS keys, queues and secrets, which grant access as surely as IAM does.

Guardrails beat findings

An audit that ends in a ticket list will be repeated next year with the same findings and new resource names. The fix that lasts is a guardrail: a control that makes the mistake impossible, or at least loud.

Preventive guardrails on AWS are service control policies in AWS Organizations, which cap what any principal in an account can do, including the account’s administrators; account-level and organisation-level S3 Block Public Access, which overrides public bucket policies and ACLs; and defaults such as requiring IMDSv2 on new instances. Detective guardrails are AWS Config rules, Security Hub controls and GuardDuty findings routed to someone who will act. Infrastructure-as-code checks, Checkov, tfsec or an OPA policy run in CI against Terraform plans, catch the problem in the pull request, which is cheaper than either. Guardrails are paved roads for infrastructure, and the Lead-level chapter on security champions and paved roads covers how to get teams onto them.

A starting SCP for a workload organisational unit, built from the policy examples in the AWS EC2 and S3 documentation:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "RequireImdsV2OnLaunch",
      "Effect": "Deny",
      "Action": "ec2:RunInstances",
      "Resource": "arn:aws:ec2:*:*:instance/*",
      "Condition": {
        "StringNotEquals": { "ec2:MetadataHttpTokens": "required" }
      }
    },
    {
      "Sid": "DenyImdsV1Downgrade",
      "Effect": "Deny",
      "Action": "ec2:ModifyInstanceMetadataOptions",
      "Resource": "arn:aws:ec2:*:*:instance/*",
      "Condition": {
        "StringNotEquals": { "ec2:Attribute/HttpTokens": "required" },
        "Null": { "ec2:Attribute/HttpTokens": "false" }
      }
    },
    {
      "Sid": "ProtectAccountPublicAccessBlock",
      "Effect": "Deny",
      "Action": "s3:PutAccountPublicAccessBlock",
      "Resource": "*",
      "Condition": {
        "ArnNotLike": { "aws:PrincipalArn": "arn:aws:iam::*:role/security-break-glass" }
      }
    }
  ]
}

The third statement matters because, per the S3 documentation, deleting the account-level Block Public Access setting needs the same s3:PutAccountPublicAccessBlock permission as changing it. The break-glass exception is deliberate: guardrails without a documented escape hatch get removed the first time they block a launch. Test any SCP in a sandbox organisational unit before attaching it to production; a deny you got wrong stops deployments for every team at once.

Beyond the console

“Infrastructure” is wider than the cloud account. Three places matter in most audits.

The CI/CD system holds the most powerful credentials in the company, because it deploys everything. Replace stored cloud keys in CI with OpenID Connect federation, so each job gets short-lived credentials scoped by repository and branch, and check that the role trust policy pins the repository rather than trusting the whole CI provider.

Kubernetes has its own CIS benchmark and its own versions of the same mistakes: a public API server, workloads running privileged, service account tokens that reach the cloud account through workload identity with more permission than the pod needs. Kubernetes and edge security takes clusters, containers and the CDN in front of them further.

Hosts and images, where they still exist, need a hardened base image built from the relevant CIS benchmark and rebuilt rather than patched in place. The vulnerability management programme owns the patching; you own the baseline.

When a finding is a breach

Some findings are incidents the moment you see them. The common one is a bucket of personal data open to the internet. Your first hour is containment and evidence, in that order: block public access on the bucket, record the policy as it was, and pull every log that could show who read it. If server access logs or CloudTrail data events were on, you may be able to say who read what. If they were off, you cannot show it was not read, and you need to say so.

Then the law, which is not yours to decide alone but is yours to trigger. Under the GDPR, a personal data breach is defined in Article 4(12) as “a breach of security leading to the accidental or unlawful destruction, loss, alteration, unauthorised disclosure of, or access to, personal data transmitted, stored or otherwise processed.” Article 33(1) says: “In the case of a personal data breach, the controller shall without undue delay and, where feasible, not later than 72 hours after having become aware of it, notify the personal data breach to the supervisory authority competent in accordance with Article 55, unless the personal data breach is unlikely to result in a risk to the rights and freedoms of natural persons. Where the notification to the supervisory authority is not made within 72 hours, it shall be accompanied by reasons for the delay.”

Four details change what you do:

  • The clock starts at awareness. The EDPB’s Guidelines 9/2022 say a controller becomes aware when it has “a reasonable degree of certainty that a security incident has occurred that has led to personal data being compromised”, and allow a short period of investigation to establish that. They also say failing to act in a timely manner can itself be a failure to notify. A short investigation is hours to a day, not the fortnight a full forensic review takes.
  • You can notify in phases. Article 33(4) lets information be “provided in phases without undue further delay” where it is not all available at once. Missing facts are a reason to notify incompletely, not a reason to wait.
  • Everything gets documented. Article 33(5) requires the controller to document every personal data breach, its effects and the remedial action, including the ones it decides not to notify.
  • Individuals are a separate test. Article 34(1) requires telling the people affected “without undue delay” when the breach is likely to result in a high risk to them. Exposed balances, addresses and identity documents usually tip that test; a list of work email addresses may not.

Who is told, then, is a short list you agree before the day: the incident lead, the data protection officer, legal, and the executive who owns the decision to notify. If you are a processor for someone else’s data, Article 33(2) requires you to tell the controller without undue delay, and the contract usually sets a shorter clock. Financial firms may also have incident-reporting duties to their own regulator with different timescales; find out which apply before you need to. Detection and incident response covers running the incident itself.

Where practitioners disagree

Central guardrails or team autonomy. One camp locks the organisation down with SCPs and a landing zone, and teams request exceptions. The other gives teams their own accounts with few restrictions and relies on detection. The first is safer and slower; the second ships faster and depends on a detection team that responds. Most companies end up with hard denies on a short list (public storage, disabling logging, leaving the organisation) and detection for the rest.

Benchmark score or risk. A CIS pass rate is easy to report and auditors like it. It also rewards closing hundreds of low-value checks while one path to customer data stays open. Report both, and lead with the paths.

Buy a CSPM or run the open-source tools. Commercial cloud security posture management products add attack-path graphs and multi-cloud coverage. Native tools plus Prowler cover most of the benchmark for little money. The tool is rarely the constraint; someone triaging its output every week is.

Day to day

The work has a weekly rhythm and a few slower cycles.

Daily, 30 to 60 minutes. Triage new findings from Security Hub, GuardDuty and Access Analyzer. Most are noise or known exceptions; the job is spotting the new public resource, the new cross-account trust, the root login. Anything touching sensitive data gets a message to the owning team the same day.

Pull-request review, several times a week. Review Terraform and policy changes that touch IAM, networking or data stores. A comment on a pull request costs minutes; the same fix after deployment costs a ticket and a sprint. Many teams route these to you automatically through code-owner rules on the IAM and network modules.

Weekly, an hour with the platform team. Walk the open high-severity findings, agree owners and dates, and decide which repeated finding should become a guardrail. This meeting is where most of the risk reduction actually happens.

Monthly. Review new accounts and who has administrator access to each. Check that the guardrails are still attached. Run a short game day: does an alert fire if someone makes a test bucket public?

Quarterly. Re-run the full audit against the benchmark at its current version, report the trend and the open attack paths to the head of security, and retire accepted risks whose expiry has passed.

Ad hoc. Architecture reviews for new services, help when a team needs a public endpoint for a real reason, and the occasional finding that turns into an incident.

BY ORG SIZE
STARTUPunder 30 people

There is no cloud security engineer; there is a founding engineer with the root password. The audit is an afternoon: turn on account-wide Block Public Access, MFA on root, CloudTrail in all regions, GuardDuty, and replace any IAM users with single sign-on. Run Prowler once and fix the paths to customer data. Put production in its own account before the second customer signs. The first serious due-diligence questionnaire will ask for all of this, and it is cheaper to have done it than to explain why not.

SCALE-UP30 to 300

The first cloud security hire arrives into dozens of accounts built by different teams with different habits. The job is a landing zone: AWS Organizations with organisational units, a small set of SCPs, central logging to an account nobody else can write to, and Security Hub aggregated in one place. The hard part is retrofitting guardrails onto running systems without breaking them, so the work is a sequence of migrations agreed with platform engineering, each with a sandbox trial and a rollback.

ENTERPRISE300 and up

There may be hundreds of accounts across two or three clouds, a cloud centre of excellence, and a CSPM product with thousands of open findings. The work is governance: exception processes with expiry dates, risk acceptance by named owners, reporting to the risk committee, and evidence for SOC 2, PCI DSS and the financial regulator. Expect politics over who may hold administrator access and whose budget pays for logging. Your leverage is the paved road: accounts vended already compliant, so teams that use it never see a finding.

ARTEFACT Write the misconfiguration audit ~90 MIN
YOU PRODUCECloud misconfiguration audit

Template

# Cloud misconfiguration audit: <account or organisation>
Author · Date · Status: draft | reviewed | remediation in progress | closed
Reviewed with: <platform lead> · <data owner> · <head of security>

## Summary
<Half a page: the paths to sensitive data you found, what is being fixed this week,
which guardrails will stop recurrence, and anything escalated as a possible incident.>

## Scope
- Accounts: <ids and purpose>
- Regions in use / regions checked for unexpected resources: <list>
- Benchmark: <name and version>   Tools: <Security Hub, Access Analyzer, Prowler ...>
- Not covered: <what you did not look at, and why>

## Sensitive data stores
| Store | Data class | Owner | Access logging on? |
|---|---|---|---|

## Internet-facing edge
| Resource | Exposure | Role or identity attached |
|---|---|---|

## Attack paths (top findings)
### P1: <entry point> -> <identity> -> <data>
- Chain: <finding A> + <finding B> + <finding C>
- Data reached: <store, approx records>
- Exploitability: <what an attacker needs>
- Severity (yours): critical | high | medium | low
- Fix now: <action>   Owner: <name>   By: <date>
- Guardrail: <SCP, setting, CI policy>

## Other findings
| ID | Resource | Finding | Benchmark ref | Severity | Owner | Due | Pile |
|---|---|---|---|---|---|---|---|

## Guardrails proposed
| Guardrail | Type (preventive/detective) | Scope | Tested in | Break-glass |
|---|---|---|---|---|

## Accepted risks
| Finding | Reason | Accepted by | Expires |
|---|---|---|---|

## Escalations
<Any finding that may be a breach: who was told, when, and the incident reference.>
WORKED EXAMPLE

Whimbrel is a fictional buy-now-pay-later lender based in Dublin: 140 people, 1.2 million customers in four EU countries, one AWS organisation with nine accounts. The new cloud security engineer audited the lending-prod account in her third week.

Summary. Two paths reach customer data. P1: the public checkout callback service runs on EC2 with IMDSv1 allowed and a role with s3:GetObject on all buckets, including the bucket of identity-document scans (about 410,000 files); an SSRF bug in the callback handler would expose them. P2: an S3 bucket of nightly collections exports (names, emails, outstanding balances, about 38,000 customers) has a bucket policy granting s3:GetObject to *, added 11 days ago for a debt-collection partner. P2 was escalated as a possible breach at 10:40 on the day of discovery. Benchmark: CIS AWS Foundations, version recorded in scope; 412 failed checks, of which 9 feed the two paths.

Fix now. P2: Block Public Access on the bucket, partner moved to a role with an external ID (owner: payments platform lead, done same day). P1: require IMDSv2 on the callback fleet and scope the role to the one bucket it writes (owner: checkout tech lead, 5 working days).

Guardrails. SCP requiring IMDSv2 and protecting account-level Block Public Access, trialled in the sandbox OU for one week. Account-level Block Public Access on all nine accounts. Checkov in the Terraform pipeline failing any policy with a wildcard principal.

Accepted. Default EBS encryption off in the analytics sandbox (no customer data; expires in 90 days).

Now you

You are the first security engineer at Knot, a fictional chat-commerce platform: merchants sell through messaging apps, Knot handles the catalogue, the chat checkout and the order history. Ninety people, four AWS accounts (prod, staging, data, sandbox). A Prowler run against the CIS AWS Foundations Benchmark reports 1,214 failed checks. Among them: three IAM users with access keys over 400 days old, one belonging to a contractor who left in spring and last used nine days ago; the webhook relay in prod, internet-facing, with IMDSv1 allowed and a role holding s3:* on all resources; a staging RDS instance marked publicly accessible, holding a copy of production chat transcripts; CloudTrail on in only one region in sandbox; GuardDuty off in data and sandbox; no MFA on the data account’s root user; and about 900 low-severity findings such as missing tags. Complications: the CTO wants the count at zero before an investor’s due diligence in three weeks, the platform team is two people, and the contractor’s key drives a nightly export a logistics partner depends on. Write the audit.

Self-check

DECIDE

You are the cloud security engineer at Whimbrel, an EU buy-now-pay-later lender. At 10:15 on a Tuesday your audit finds an S3 bucket of nightly collections exports, with names, emails and outstanding balances for about 38,000 customers, readable by anyone for the last 11 days through a bucket policy added for a partner. Server access logging and CloudTrail data events were off on that bucket, so you cannot tell whether anyone outside read it. You have already blocked public access. Who do you tell, and when?

READING
  1. DOC
    Security Pillar, AWS Well-Architected Framework Amazon Web Services

    The reasoning behind the checklist: seven design principles and seven practice areas. Read the identity and data-protection sections before your first audit, and use its language when you explain a finding to engineers.

  2. DOC
    CIS Amazon Web Services Benchmarks Center for Internet Security

    The consensus checklist most audits and auditors use, free for non-commercial use. Download the Foundations Benchmark, note its version, and read the rationale for each recommendation rather than only the check.

  3. DOC
    United States v. Paige Thompson: case page, complaint and indictment US Attorney's Office, Western District of Washington

    The primary record of the Capital One intrusion. Read the complaint's investigation section: three commands, a WAF role, more than 700 buckets listed, and logs that showed it after the fact.

  4. DOC
    Information on the Capital One cyber incident Capital One

    The company's own account: dates, how it learned of the issue through responsible disclosure, and counts of affected people and identifiers. Compare it with the complaint to see how a breach statement is written.

  5. DOC
    OCC assesses $80 million civil money penalty against Capital One Office of the Comptroller of the Currency, 2020

    The regulator's view: the penalty was for failing to assess risk before moving significant operations to the public cloud and for slow remediation, not only for the intrusion. Read it as what a board will be asked afterwards.

  6. DOC
    Guidelines 9/2022 on personal data breach notification under GDPR European Data Protection Board, 2023

    The authoritative reading of Articles 33 and 34: when a controller becomes aware, notification in phases, processors, and worked examples. Read sections II and the examples before you write your incident runbook.

  7. POST
    Add defense in depth against open firewalls, reverse proxies, and SSRF vulnerabilities with enhancements to the EC2 Instance Metadata Service Colm MacCárthaigh, 2019

    Why IMDSv2 exists and exactly which attacks each of its mechanisms blocks. The clearest short explanation of how a reachable workload hands over its role credentials.

  8. CODE
    Prowler Prowler

    An open-source scanner that runs the CIS benchmarks and other frameworks across AWS, Azure, Google Cloud and Kubernetes. Run it against a sandbox account and read the checks it fails before you trust any tool's severity.

All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: Detection and incident response →