Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 38 ยท Compliance and Governance

Posture Management and Cloud Misconfiguration

Learn why misconfiguration is the top cloud risk, how CSPM tools and CIS benchmarks find it, how to prioritise findings and detect configuration drift, with runnable scanners.

Most cloud breaches do not involve a clever zero-day exploit. They start with a setting that was left open: a storage bucket readable by everyone, a database with a public address and no password, a firewall rule that allows administration from the whole internet or an access key with administrator rights that ended up in a public repository. Cloud services are configured through APIs, so a single mistaken checkbox or line of template code can expose data to the world within seconds.

Cloud Security Posture Management (CSPM) is the practice, and the family of tools, for continuously checking cloud configuration against best practices and rules. Examples are the cloud providers' own services (AWS Security Hub and Config, Microsoft Defender for Cloud, Google Security Command Center) and third-party platforms. In this lesson you will learn the typical findings, how scanners work and how to prioritise results, then you will build a scanner of your own over an invented inventory.

Scan only accounts you own or are explicitly authorised to assess. Scanning other people's cloud resources is not allowed, even when a misconfiguration is visible from the outside.

The usual suspects

Area Typical misconfiguration Why it hurts
Storage Public read or write on buckets; no encryption; no versioning Data leaks, ransomware, data loss
Identity Root account without MFA; users with *:*; unused old keys Account takeover and privilege escalation
Network 0.0.0.0/0 open to SSH (22), RDP (3389) or databases Brute force and exploitation from anywhere
Compute Public instances with old images; instance metadata v1 enabled Credential theft via SSRF
Databases Public endpoints; no TLS; default passwords; no backups Data theft and loss
Logging Audit logs off or only in one region No evidence during incidents
Secrets Keys in code, in environment variables or in public snapshots Direct credential leaks
Kubernetes Public API server, privileged pods, no network policy Cluster takeover

Industry checklists such as the CIS Foundations Benchmarks for AWS, Azure and Google Cloud turn these into numbered, testable checks, for example "ensure MFA is enabled for the root account" or "ensure no security group allows ingress from 0.0.0.0/0 to port 22". Many findings also map to the frameworks in compliance frameworks overview.

How a CSPM scanner works

flowchart LR
    A["Read-only API access to each account"] --> B["Collect inventory<br/>(buckets, VMs, IAM, rules)"]
    B --> C["Evaluate checks<br/>(CIS and custom rules)"]
    C --> D["Prioritise: severity,<br/>exposure, data value"]
    D --> E["Findings, tickets, dashboards"]
    E --> F["Fix or auto-remediate"]
    F --> A

A continuous loop: collect, evaluate, prioritise, fix, repeat.

A scanner needs only read-only permissions, such as the managed SecurityAudit and ViewOnlyAccess roles, which also keeps the scanner itself from becoming a high-value target. Never give a scanning tool write access unless you have deliberately chosen auto-remediation.

Try it: scan an inventory with CIS-style checks

The inventory below is a simplified, invented description of a small account. Each check is a function from resource to finding.

Python Scan a cloud inventory for misconfigurations

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The report is sorted by severity. Three critical findings (public bucket, root without MFA, public database) deserve action before anything else.

Prioritising: not all findings are equal

A real account can have thousands of findings. Fix the ones an attacker can actually use first. Good prioritisation weighs:

  • Exposure: is the resource reachable from the internet?
  • Privilege: what could an attacker do with it (admin role, data access)?
  • Data sensitivity: does it hold customer or regulated data?
  • Exploitability: is there a known vulnerability or leaked credential?
  • Combinations ("toxic combinations"): an internet-facing VM with a critical vulnerability and an over-privileged role is much worse than any of the three alone.

Try it: score findings by combination

Python Raise priority for toxic combinations

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

vm-web-1 leads by a wide margin, because the three risk factors reinforce each other. vm-batch has the same vulnerability and role but is not reachable from outside, so it can wait.

Drift and continuous monitoring

Configuration that was correct on the day you deployed it may not stay correct. Someone changes a rule in the console during an outage and forgets to revert it. Drift detection compares the live state with the intended state (from your infrastructure-as-code or an approved baseline) and reports differences.

Python Detect configuration drift

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Both kinds of drift matter: changed settings and shadow resources that were never in code. Investigate each one. If the change was an emergency fix, put it into code properly; if it was unauthorised, treat it as a possible incident (see cloud incident response).

Remediation options

  1. Prevent: policy as code and organisation guardrails block the mistake (policy as code).
  2. Fix at the source: change the template, not just the live resource, so the next deployment does not undo the fix.
  3. Auto-remediate low-risk, well-understood cases (for example re-enabling bucket encryption), with logging and notifications.
  4. Ticket with an owner for the rest, with a due date by severity.
  5. Accept the risk only with a written reason, an owner and an expiry date.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What kind of permissions should a CSPM scanner normally have?

    Scanners only need to read configuration. Read-only roles keep the tool from becoming a powerful target.
  2. 2. Which finding is usually the most urgent?

    Internet exposure of sensitive data gives attackers direct access, so it ranks above hygiene findings.
  3. 3. What is configuration drift?

    Drift appears when someone changes live resources outside the normal pipeline, or when unmanaged resources appear.
  4. 4. Why fix the infrastructure-as-code template as well as the live resource?

    The template is the source of truth. If it still contains the insecure value, the problem returns on the next deployment.

Summary

  • Misconfiguration, not exotic exploits, causes most cloud breaches: public storage, open ports, weak identity settings and disabled logging lead the list.
  • CSPM tools collect inventory with read-only access and evaluate it against checks such as the CIS Benchmarks.
  • Prioritise by exposure, privilege, data sensitivity, exploitability and toxic combinations.
  • Detect drift and shadow resources, then fix at the source, auto-remediate safe cases and document any accepted risk.

Next: Data Privacy and Residency