Circuit Times
Subscribe

Cloud Security Fundamentals: Controls, Tests and Checklist

Cloud security fundamentals with a real scanner test: shared responsibility, core controls, risk ranking and a 90-day plan.

  • 26 min read
  • 38 sections
  • Published November 23, 2026
Lena Marlowe

Explainer

Cloud security is the set of practices and tools that protect data, applications and infrastructure that run on cloud services. It covers who can sign in, what each person and program may do, how data is encrypted, how systems are configured, what gets logged and how you recover when something goes wrong.

Most guides to cloud security list best practices without showing what a mistake looks like. This one adds a hands-on test. I wrote a small, deliberately insecure cloud configuration, scanned it with an open-source tool, fixed it and scanned it again, so you can see which mistakes a scanner catches, which it misses and how much work remains.

The statements about AWS, Azure and the UK's National Cyber Security Centre come from their own documentation, which I read on October 28, 2026. The scan results are real output from Checkov version 3.3.30. The risk scores and checklists are our own analysis, and any numbers in them are invented to show the math.

The short answer

Cloud providers secure the underlying infrastructure, and you secure what you put on it. For most teams, that means getting five things right: identity and access, data protection, configuration, logging and recovery. Many serious cloud incidents involve a customer-side mistake, such as an exposed storage bucket or a powerful account with a weak login. I did not find a source that gives the exact share, so treat this as a common pattern and not a statistic.

Start with the controls that block the most damage: multi-factor sign-in, least privilege, no public data stores, encryption, logging that someone reads and backups you have tested. Then automate checks so mistakes are caught before they reach production.

Good to know

Services and defaults change often. Check your provider's current documentation before you rely on any setting described here.

What cloud security covers

Cloud security spans several layers. Each layer has its own risks and its own controls.

LayerWhat it includesTypical risk
IdentityUsers, roles, keys and sign-inStolen or over-powerful credentials
NetworkFirewalls, subnets and exposure to the internetServices reachable by anyone
DataStorage, databases and backupsUnencrypted or public data
ComputeVirtual machines, containers and functionsUnpatched software
ConfigurationSettings across every serviceInsecure defaults and drift
ApplicationsYour own code and its dependenciesFlaws in code and libraries
OperationsLogging, alerting and responseAttacks nobody notices

Cloud security is not one product. It is a collection of habits and controls, spread across every service you use. That is why a clear picture of who is responsible for what comes first.

The cloud service models

How much you must secure depends on the kind of service you use. Microsoft's documentation describes the three common models and who manages what.

ModelWhat you manageWhat the provider manages
Infrastructure as a serviceVirtual machines, operating systems and applicationsPhysical hosts, network and datacenter
Platform as a serviceYour application and its data, without managing virtual machines or operating systemsThe platform, operating system and below
Software as a serviceYour data, users and settingsThe application and everything beneath it

The further toward software as a service you go, the less you manage and the less control you have. Even so, some duties never move to the provider, as the next section shows.

Shared responsibility

Major providers each publish a shared responsibility model. AWS splits duties into protection of the cloud itself and protection of what customers place in it. Its own side covers the infrastructure behind its services: the hardware, software, networking and facilities. The customer's side varies with the services the customer picks.

Microsoft's documentation adds that regardless of the type of deployment, you always keep certain responsibilities. It lists your data, including its classification, protection, encryption decisions and compliance with governance requirements, and the endpoints that access your cloud services, such as laptops and mobile devices. Identity and access are also yours to manage.

What this means in practice

If a bucket of customer files is public, that is almost always a customer configuration choice. If a physical server in a datacenter fails, that is the provider's problem. Between those lie many gray areas, such as patching a virtual machine, which is yours in an infrastructure service and the provider's in a software service.

Write down, for each service you use, who handles patching, backups, encryption keys, logging and access control. Gaps in that list are where incidents come from.

The NCSC's 14 cloud security principles

The UK's National Cyber Security Centre publishes 14 cloud security principles. They are designed for choosing and assessing cloud services, and they make a useful checklist for any organization. This table lists them with a short plain-language reading of each, which is my own summary.

PrincipleWhat it asks
1. Data in transit protectionIs data protected while it moves across networks?
2. Asset protection and resilienceIs data protected and recoverable where it is stored?
3. Separation between customersCan one customer affect or see another?
4. Governance frameworkDoes the provider manage security with clear roles and processes?
5. Operational securityDoes the provider manage vulnerabilities, changes and incidents well?
6. Personnel securityAre staff screened and their access limited?
7. Secure developmentIs the service built and tested securely?
8. Supply chain securityAre the provider's own suppliers managed?
9. Secure user managementCan you control and see who uses the service?
10. Identity and authenticationIs access limited to authorized users?
11. External interface protectionAre exposed interfaces protected?
12. Secure service administrationAre administration methods secure?
13. Audit information and alerting for customersCan you get the logs and alerts you need?
14. Secure use of the serviceDo you use the service securely?

The last principle is the one that falls on you. Even a very secure service can be used insecurely. Our multi-tenant SaaS guide shows how separation between customers can fail in practice, and the tests I ran on a database.

The core controls

These are the controls that matter most. This table is our analysis, with the typical failure for each.

Control areaWhat to doTypical failure
Identity and accessUse multi-factor sign-in, give each person and program only the access it needs, and review itShared accounts, administrator rights for everyone
Data protectionEncrypt data at rest and in transit, and manage keys carefullyUnencrypted stores, keys in code
ConfigurationDefine settings as code, and scan them before deploymentManual changes and configuration drift
Network exposureKeep management interfaces and databases off the public internetOpen administrative ports
Logging and monitoringRecord who did what, send logs to a protected place and review alertsLogs turned off or never read
PatchingUpdate systems and track known exploited flawsOld software on exposed servers
Backup and recoveryKeep copies in a separate account, and test restoresBackups never tested, or deletable by an intruder
Secrets managementStore keys and passwords in a vault, and rotate themPasswords in code and chat

Our guide to MFA methods ranks second factors from weakest to strongest. Central sign-in is covered by our single sign-on guide, and our privileged access management guide explains how to limit the most powerful accounts.

Identity is the new perimeter

In the cloud, anyone who can sign in with the right credentials can reach your resources from anywhere. That makes identity the main line of defense. Attackers know this, and they target logins, access keys and the tokens that programs use.

Give every human a personal account with multi-factor authentication. Give every program its own identity with limited permissions, and avoid long-lived keys. Remove access when people change roles or leave. Review administrator accounts often.

Least privilege in practice

Least privilege means granting only the permissions needed for the job. It is easy to say and hard to do, because broad permissions are quicker to set up. A wildcard policy that allows every action on every resource is the opposite, and the test below shows how many problems it triggers.

A hands-on test with a scanner

To see what misconfigurations look like and what scanners catch, I wrote a small Terraform file that describes six cloud resources on AWS. I made it insecure on purpose. Then I scanned it with Checkov, an open-source tool that checks infrastructure code against a library of rules.

The insecure file defined these resources.

ResourceWhat I did wrong
Storage bucket with a public-read access control listMade customer data readable by anyone
Security group that allows SSH from anywhereExposed an administration port to the internet
Database instance that is publicly accessible and unencryptedExposed a data store and left it unprotected at rest
IAM policy allowing every action on every resourceGave a wildcard permission
Storage volume that is unencryptedLeft data unprotected at rest
A hard-coded database passwordPut a secret in the code

Checkov's Terraform checks ran 48 checks across the six resources. 15 passed and 33 failed.

ResourceFailed checks
Database instance11
IAM policy9
Storage bucket8
Security group3
Storage volume2

The most serious failures were easy to read. The scanner reported that the bucket had an access control list allowing public read access, that a security group allowed ingress from anywhere to port 22, that the database was publicly accessible and not encrypted at rest, that the volume was not encrypted and that the policy allowed wildcard actions and administrative privileges.

Many of the 33 failures were less urgent. They asked for things like access logging, event notifications, lifecycle rules, cross-region replication, performance insights and enhanced monitoring. Those are good practices that depend on your needs, and they add noise.

What the scanner missed

The Terraform checks did not report the hard-coded password. None of the 33 failures was about the password. Checkov has a separate secrets mode, and when I ran that, it flagged the line with the password. The lesson is that no single tool covers everything. Run secrets scanning as well as configuration scanning.

Fixing it

I then wrote a hardened version. It added a key for encryption with rotation, a public access block and encryption on the bucket, versioning, a security group restricted to one office network range, shown with a documentation-only placeholder address that must be replaced, a private and encrypted database with backups, deletion protection and managed credentials, a narrow policy with two actions on one bucket, and an encrypted volume.

I wrote this file for static scanning only. I did not deploy it, and it is not a complete or ready-to-deploy account design. The office address in the security group is a documentation-only placeholder range that you must replace with your own trusted range. The file also omits items that a real deployment needs, such as a database subnet group, a key policy that fits your roles and a destination for logs. Passing a scan shows that selected rules are met, and it does not show that an account is secure.

ScanChecks runPassedFailed
Insecure version481533
Hardened version544311

The hardened version still failed 11 checks. I judged each of them to be a hygiene or resilience item that depends on your needs, though you should review every one for your own case. The items included access logging on the bucket, replication, lifecycle rules, query logging, performance insights, enhanced monitoring and a key policy. A scanner will keep finding things, and a score of zero failures is not the goal. The goal is to remove the serious problems first and to decide, on purpose, which remaining items you accept.

How to use a scanner well

Run it in the pipeline

Scan every change before it merges, so mistakes never reach production. Our GitHub vs GitLab comparison covers the pipelines where this runs.

Rank findings by severity

Fix public exposure, wildcard permissions and missing encryption first.

Suppress with a reason

If you accept a finding, record why, and review it later.

Scan the running cloud too

Code can drift from reality when people change settings by hand.

Add secrets scanning

It catches what configuration checks miss.

Do not trust a green result blindly

A scanner only checks what its rules cover.

The Terraform files and the commands to run the scan are in the reproduce section at the end.

Ranking what to fix first

Real environments produce hundreds of findings. You need a way to rank them. A simple method scores each finding on three questions: how exposed is it, how sensitive is the data and how much power does it give an attacker.

I used a scale of 0 to 3 for each, and multiplied the scores after adding 1 to each, so a zero does not erase the others. The maximum is 4 times 4 times 4, which is 64. The scales and the method are my own, and the values are judgments.

Finding from my testExposureData sensitivityPrivilegeScore
Hard-coded database password23236
Public customer data bucket33132
Public unencrypted database33132
SSH open to the internet31224
Wildcard IAM policy12324
Unencrypted volume0203
No access logging0102

The ranking puts the password and the public data stores first, and logging last. That is the right shape: close the doors first, then improve visibility. Adjust the scales to your own data. A product that holds health records scores its data higher than one that holds public documents.

Data protection

Data is usually the thing an attacker wants. Protect it where it sits, while it moves and when you recover it.

Encryption at rest

Turn it on for storage, databases and backups. In my scan, three separate checks failed because data was not encrypted at rest.

Encryption in transit

Require secure connections between users, services and databases.

Key management

Use the provider's key service, rotate keys and limit who can use them. Never place keys in code.

Classification

Know which data is sensitive, so you can protect it more strongly.

Access

Grant access to data by role, and log every read of sensitive stores.

Deletion

Remove data you no longer need, because stored data is data that can leak.

Encryption helps only if keys and access are controlled. An encrypted bucket that any account can read through a loose policy is not protected.

Backup and recovery

Backups are your last line of defense against ransomware, mistakes and failures. They fail in predictable ways. Backups live in the same account as the data, so an intruder deletes both. Nobody tests a restore until the day it matters. Backups run too rarely to be useful.

Two numbers drive the design. The recovery point is how much data you can afford to lose, which backup frequency controls. The recovery time is how long you can be down, which restore speed controls.

I modeled a system with 500 GB of data. Backups every 24 hours risk losing up to 24 hours of data, every 6 hours up to 6 hours and every hour up to 1 hour. Restore time depends on throughput.

Restore speed (decimal units)Time to restore 500 GB
100 MB per secondAbout 83 minutes
25 MB per secondAbout 333 minutes, or about 5.6 hours

A fourfold difference in speed changes a short outage into most of a working day. Test your actual restore speed, because the number on a plan is rarely the number you get.

Keep copies in a separate account with separate credentials, and make them immutable where the service allows. Test a full restore at least once a year, and after major changes.

Network exposure

Internet-facing systems are scanned constantly by automated tools, and a newly exposed service can start receiving probes quickly. I did not measure how quickly, and it varies. Reduce what is reachable. Keep databases and internal services on private networks, and put administration behind a controlled path.

In my test, the security group allowed SSH from anywhere, and the scanner flagged it. In the hardened version, I limited it to one office range, using the placeholder address 203.0.113.0/24, which is reserved for documentation and must be replaced with your real office range. In practice, many teams go further and remove direct administration access, using a managed access service with sign-in and logs.

Check exposure from the outside as well as the inside. List every public address, port and hostname, and compare it with what you think is public. Surprises are common, especially with test systems that were never removed.

Edge devices deserve extra care, because they sit on the boundary and attackers favor them. Our zero-day vulnerability guide shows that nearly half of zero-days exploited in 2025 hit enterprise products, with a large share in security and networking gear.

Patching and known exploited flaws

Cloud workloads run software that needs updates. Virtual machines need operating system patches. Containers need base image updates. Libraries need version updates. Managed services patch themselves, but you still control versions and settings.

Prioritize patches for internet-facing systems and for flaws that attackers are known to use. CISA's catalog of known exploited vulnerabilities lists them. In my analysis of that catalog, a quarter of entries had CVE identifiers from 2018 or earlier, which shows how long old flaws stay useful to attackers. Our zero-day guide includes the models for patch speed and priority scoring.

Logging and detection

You cannot respond to what you cannot see. Cloud providers offer logs of administrative actions and, separately, logs of network and application activity. Turn them on, send them to a place that an intruder cannot easily erase and make sure a person or an automated rule reads them.

Log sourceWhat it showsExample alert
Administrative activityWho changed what in the accountA new administrator created at night
Sign-in eventsSuccessful and failed loginsMany failures, then a success
Network flowTraffic between systemsA server sending large data to an unknown address
Application logsWhat your software didA spike in errors or unusual requests
Storage accessWho read or wrote dataA bulk download from a sensitive bucket
Key useWho used encryption keysA key used from a new location

Logs cost money to store. I modeled 200 servers that each produce 50 MB of logs a day. That is 10 GB a day. Keeping 90 days needs 900 GB, and keeping a year needs 3,650 GB. The NCSC's thirteenth principle asks that customers can get the audit information and alerts they need, which is also a prompt to ask what your provider supplies.

Decide retention by need. A short retention for noisy network logs and a longer one for administrative and sign-in logs is common. Keep what you need for investigations and for any rules that apply to you.

Alerts people act on

An alert that nobody reads is not a control. Start with a few high-value alerts: new administrators, changes to logging, sign-ins without multi-factor authentication, public exposure of storage and use of the most powerful accounts. Tune them until each one is worth waking someone for.

Common cloud security risks

This table lists the risks that appear most often. It is our analysis, based on the controls above.

RiskWhat it looks likeMain defense
MisconfigurationA public bucket or open portConfiguration as code, scanning and review
Over-privileged accountsWildcard policies, administrator rights for allLeast privilege and regular review
Weak sign-inPasswords without a second factorMulti-factor authentication
Leaked keys and secretsKeys in code, chat or logsVaults, rotation and secret scanning
Unpatched systemsOld software on exposed serversInventory and fast patching
Insecure interfacesUnprotected or unauthenticated APIsAuthentication, rate limits and testing
Missing logsNo record of what happenedCentral, protected logging
Shadow ITServices bought without reviewApproval process and discovery
Supply chainCompromised libraries or imagesPinned versions, scanning and trusted sources
Weak recoveryUntested backupsSeparate copies and restore drills

Software as a service and third-party apps

Many organizations use dozens of software as a service products. The provider secures the application, but you still control who signs in, what data goes in and which other apps connect. Common problems include accounts without multi-factor authentication, former employees whose access remains and third-party apps granted broad permissions.

Use central sign-in where you can, and review connected apps regularly. Our single sign-on guide explains how central sign-in reduces risk, and our guide to SaaS authentication compares the options if you are building a product.

Containers and serverless

Containers and serverless functions change who patches what. In containers, you update base images and libraries. In serverless, the provider runs the infrastructure, and you secure the code, its permissions and its inputs.

Give each workload its own narrow identity

A function that reads one bucket should not be able to delete the account.

Scan images and dependencies

Check them before they ship.

Pin versions

Know exactly what runs.

Limit network paths

Allow only the connections that are needed.

Keep secrets out of images

Inject them at run time.

Building security into delivery

Security works best when it is part of how you build, not a gate at the end. Put checks in the pipeline: scan configuration and secrets, check dependencies for known flaws and require review for changes to permissions and network rules.

Treat infrastructure as code. When settings live in files under version control, you can review changes, roll them back and scan them automatically. When people click through consoles, you lose the record, and settings drift from what you think they are.

Our SaaS starter kits comparison shows how to review a kit's dependencies and defaults before you build on it, which applies to any code you bring into your cloud.

To know which dependencies a workload contains, keep a software bill of materials for it. Our SBOM guide shows what one lists and what generators leave out.

For the application layer, our OWASP Top 10 guide walks through the ten risk categories with a tested example of each.

To choose scanners for the pipeline, see our SAST vs DAST vs SCA comparison, which runs four tools against one app with planted flaws.

Compliance and frameworks

Frameworks give structure. The NCSC principles above help you assess services. Other widely used frameworks and benchmarks list controls in more detail, and many customers ask which you follow. Pick a framework that fits your customers and region, map your controls to it and keep evidence.

Compliance is not the same as security. A company can meet a framework and still have gaps, and a company can be secure without a certificate. Use frameworks as a guide, and test your real controls.

Cloud security tools

Several tool categories exist. Names vary, and products often combine them.

CategoryWhat it does
Cloud security posture managementContinuously checks cloud settings against rules
Infrastructure as code scanningChecks configuration files before deployment, as Checkov does
Secrets scanningFinds keys and passwords in code and logs
Workload protectionWatches servers and containers for threats
Cloud access security brokerMonitors and controls use of software as a service
Identity governanceReviews who has access to what
Log and event analysisCollects and analyzes logs and raises alerts

You do not need every category. Start with identity controls, configuration scanning and logging, then add others as your environment grows.

Identity hygiene in detail

Identity problems cause a large share of cloud incidents, so it is worth going beyond the basics. These checks apply to any provider.

CheckWhat to look for
Root or owner accountUsed only for rare tasks, protected by a hardware key or strong multi-factor sign-in, with no access keys
Human usersPersonal accounts, multi-factor sign-in and central sign-in where possible
Service identitiesOne per workload, with narrow permissions
Long-lived keysReplace them with short-lived credentials where the platform supports it
Unused accounts and keysDisable what has not been used for a set period
Administrator groupSmall, reviewed often, with changes logged
Cross-account accessDocumented and limited to named roles
Emergency accessA tested break-glass account, stored safely and alarmed

The root account deserves special mention, because it can do anything. Many teams create it, protect it and never touch it again. Keep its sign-in details in a safe place, and set an alert for any use.

Review access on a schedule. Every quarter, list who can administer each account, and remove anyone who no longer needs it. People accumulate permissions over time, and old access is a favorite route for attackers.

Separating accounts and environments

A single cloud account for everything makes every mistake bigger. Splitting work into several accounts or projects limits the damage when one is compromised.

A common pattern uses separate accounts for production, development and testing, plus one for security logs and one for backups. A stolen key in the testing account cannot touch production data, and an intruder cannot erase the logs that record what happened.

I modeled the blast radius with invented numbers. Suppose a company runs 20 services and a leaked credential gives access to everything in one account. With one account, all 20 services are exposed. If services are spread over four accounts of five each, a single leaked credential exposes five.

LayoutServices reachable with one leaked credentialShare of the estate
One account20100%
Four accounts525%
Ten accounts210%

More accounts mean more to manage, so use central tools for identity, logging and policy. The principle is to size your boundaries so that one failure does not reach everything.

Preparing for an incident

Plan before something goes wrong. A short list of first actions saves time when stress is high.

First actionWhy
Confirm and record what you seeA clear picture prevents wrong moves
Contain the accessDisable or rotate the credential, and block the route
Preserve evidenceKeep logs and snapshots before changing systems
Find the scopeWhich accounts, data and systems were touched
Tell the right peopleLeaders, legal, customers as required
Recover safelyRestore from clean backups, and close the route first
LearnRecord what happened, and fix the gap

Credentials are often the cause. Know how to rotate every key and token quickly, and keep the list of where each one is used. Our privileged access management guide covers limiting what an intruder can do with a stolen powerful account.

What security costs, and where to start

Not every control costs the same, and not every organization can do everything at once. This table is our judgment of where to start by size.

OrganizationStart withAdd next
Solo founder or tiny teamMulti-factor sign-in, private storage, automatic updates, backupsLogging and a simple scanner in the pipeline
Small companyThe above, plus least privilege and central sign-inSeparate accounts and alerts
Growing companyThe above, plus configuration as code and secrets scanningPosture management, formal reviews and exercises
Large organizationThe above, at scale, with central governanceDedicated security staff and continuous testing

Some of the cheapest controls are also among the most useful. Multi-factor sign-in, private data stores and tested backups cost little and address many common attacks, though no control stops them all. Add expensive tools once you have the basics.

Questions to ask a cloud vendor

Before you rely on a service, ask questions drawn from the NCSC's principles.

  • How is my data separated from other customers' data?
  • Is data encrypted in transit and at rest, and who controls the keys?
  • What logs can I get, and for how long?
  • How do you manage vulnerabilities and tell customers about incidents?
  • Who at your company can access my data, and how is it limited?
  • What happens to my data if I leave?
  • Which certifications or audits can you share?
  • What parts of security are my responsibility for this service?

The last question matters most. A vendor who cannot clearly state your share of the responsibility is a risk.

Getting started: a 90-day plan

This plan is our suggestion.

Days 1 to 15

Take stock. List accounts, services, public addresses and who administers what.

Days 16 to 30

Secure identity. Require multi-factor authentication, remove unused accounts and review administrator rights.

Days 31 to 45

Close exposure. Make data stores private, restrict administration ports and enable encryption.

Days 46 to 60

Turn on logging. Send logs to a protected place, and create a short list of alerts.

Days 61 to 75

Automate checks. Add configuration and secrets scanning to the pipeline.

Days 76 to 90

Test recovery. Restore from backup, and rehearse your response to a lost credential.

Myths about cloud security

Some beliefs lead teams to skip controls. This table lists common ones and what is more accurate.

MythWhat is more accurate
The provider secures everythingThe provider secures the infrastructure, and you secure your data, access and configuration
Encryption alone protects dataKeys and access control decide who can read it
Small companies are not targetsAttackers scan the internet for exposed systems and do not choose by size
A scanner result of zero means safeA scanner checks only what its rules cover, and it missed a hard-coded password in my test
Cloud is always more secure than a server roomIt can be, with good configuration and access control, and it can be worse without them
Compliance means secureIt shows you met a framework and does not prove you have no gaps

Measuring progress

Track a handful of numbers, and review them monthly. They show whether your cloud security is improving.

MeasureWhat it shows
Share of human accounts with multi-factor sign-inStrength of identity controls
Number of public data storesExposure
Findings by severity, and age of open onesHow fast you fix problems
Share of changes scanned before deploymentCoverage of automation
Time to rotate a leaked credentialReadiness
Last successful restore testConfidence in recovery
Alerts handled per weekWhether detection works

A falling number of high-severity findings and a rising share of scanned changes are good signs. A last restore date from last year is a warning.

Common mistakes

Assuming the provider handles it

Shared responsibility means you handle your part.

Public data by accident

Check every store.

Broad permissions

Wildcard policies grant far more than needed.

No second factor

Passwords alone are weak.

Secrets in code

They leak through repositories and logs.

Logs nobody reads

Detection needs people or rules.

Untested backups

A restore that fails is discovered too late.

Trusting one scanner

Tools miss things, as my test showed.

Chasing zero findings

Focus on serious ones first.

Manual changes

They cause drift and hide history.

Reproduce the test

This script writes the two Terraform files I used, installs and runs Checkov, runs its secrets mode and calculates the ranking, backup and log storage figures. Use a virtual environment for the install. The Terraform examples are for static scanning only and are not meant to be deployed unchanged, because they use placeholder values such as the documentation-only address 203.0.113.0/24 and a sample password. Checkov's rule library changes between versions, so your counts may differ from mine, which used version 3.3.30.

mkdir -p insecure hardened
cat > insecure/main.tf <<'TF'
resource "aws_s3_bucket" "data" {
  bucket = "example-customer-data"
}

resource "aws_s3_bucket_acl" "data" {
  bucket = aws_s3_bucket.data.id
  acl    = "public-read"
}

resource "aws_security_group" "admin" {
  name = "admin-access"
  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_db_instance" "main" {
  identifier          = "app-db"
  engine              = "postgres"
  instance_class      = "db.t3.medium"
  allocated_storage   = 20
  publicly_accessible = true
  storage_encrypted   = false
  username            = "admin"
  password            = "changeme123"
}

resource "aws_iam_policy" "app" {
  name = "app-policy"
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect   = "Allow"
      Action   = "*"
      Resource = "*"
    }]
  })
}

resource "aws_ebs_volume" "logs" {
  availability_zone = "us-east-1a"
  size              = 50
  encrypted         = false
}
TF

cat > hardened/main.tf <<'TF'
resource "aws_kms_key" "data" {
  description         = "data key"
  enable_key_rotation = true
}

resource "aws_s3_bucket" "data" {
  bucket = "example-customer-data"
}

resource "aws_s3_bucket_public_access_block" "data" {
  bucket                  = aws_s3_bucket.data.id
  block_public_acls       = true
  block_public_policy     = true
  ignore_public_acls      = true
  restrict_public_buckets = true
}

resource "aws_s3_bucket_server_side_encryption_configuration" "data" {
  bucket = aws_s3_bucket.data.id
  rule {
    apply_server_side_encryption_by_default {
      sse_algorithm     = "aws:kms"
      kms_master_key_id = aws_kms_key.data.arn
    }
  }
}

resource "aws_s3_bucket_versioning" "data" {
  bucket = aws_s3_bucket.data.id
  versioning_configuration {
    status = "Enabled"
  }
}

resource "aws_security_group" "admin" {
  name        = "admin-access"
  description = "SSH from the office network only"
  ingress {
    description = "SSH from office"
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["203.0.113.0/24"]
  }
}

resource "aws_db_instance" "main" {
  identifier                          = "app-db"
  engine                              = "postgres"
  instance_class                      = "db.t3.medium"
  allocated_storage                   = 20
  publicly_accessible                 = false
  storage_encrypted                   = true
  kms_key_id                          = aws_kms_key.data.arn
  iam_database_authentication_enabled = true
  backup_retention_period             = 7
  multi_az                            = true
  deletion_protection                 = true
  auto_minor_version_upgrade          = true
  username                            = "dbadmin"
  manage_master_user_password         = true
}

resource "aws_iam_policy" "app" {
  name = "app-policy"
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect   = "Allow"
      Action   = ["s3:GetObject", "s3:PutObject"]
      Resource = "arn:aws:s3:::example-customer-data/*"
    }]
  })
}

resource "aws_ebs_volume" "logs" {
  availability_zone = "us-east-1a"
  size              = 50
  encrypted         = true
  kms_key_id        = aws_kms_key.data.arn
}
TF

pip install checkov==3.3.30
for dir in insecure hardened; do
  checkov -d $dir --framework terraform --compact --quiet -o json > $dir.json
done
checkov -d insecure --framework secrets --compact --quiet

python3 - <<'PY'
import collections
import json

for name in ("insecure", "hardened"):
    data = json.load(open(f"{name}.json"))
    data = data[0] if isinstance(data, list) else data
    summary = data["summary"]
    by_resource = collections.Counter(item["resource"] for item in data["results"]["failed_checks"])
    print(name, "passed", summary["passed"], "failed", summary["failed"], dict(by_resource))

findings = {
    "Hard-coded database password": (2, 3, 2),
    "Public customer data bucket": (3, 3, 1),
    "Public unencrypted database": (3, 3, 1),
    "SSH open to the internet": (3, 1, 2),
    "Wildcard IAM policy": (1, 2, 3),
    "Unencrypted volume": (0, 2, 0),
    "No access logging": (0, 1, 0),
}
for label, (exposure, sensitivity, privilege) in sorted(findings.items(), key=lambda item: -((item[1][0] + 1) * (item[1][1] + 1) * (item[1][2] + 1))):
    print(label, (exposure + 1) * (sensitivity + 1) * (privilege + 1))

for backups, hours in (("daily", 24), ("every 6 hours", 6), ("every hour", 1)):
    print("backup", backups, "worst-case data loss", hours, "hours")
for speed in (100, 25):
    print("restore 500 GB at", speed, "MB per second:", round(500 * 1000 / speed / 60), "minutes")
print("log storage, 200 servers at 50 MB a day: 90 days", 200 * 50 * 90 / 1000, "GB; 365 days", 200 * 50 * 365 / 1000, "GB")
PY

Frequently asked questions

What is cloud security?

The practices and tools that protect data, applications and infrastructure running on cloud services, including identity, encryption, configuration, logging and recovery.

What are cloud security fundamentals?

Identity and access control, data protection, secure configuration, network limits, logging and monitoring, patching and tested backups, all based on knowing what you are responsible for.

What is the shared responsibility model?

A division of duties. AWS describes it as security of the cloud, which the provider handles, and security in the cloud, which the customer handles. Microsoft says customers always keep responsibility for their data and endpoints.

What are cloud security best practices?

Use multi-factor sign-in, least privilege, encryption, private data stores, central logging, fast patching, configuration scanning and tested backups. Automate checks in your pipeline.

What are the biggest cloud security risks?

Misconfiguration, over-privileged accounts, weak sign-in, leaked secrets, unpatched systems, insecure interfaces, missing logs and weak recovery.

What does cloud security cost?

It depends on the tools and the logging volume you choose. Many controls, such as multi-factor sign-in and private storage, cost little. Log storage grows with volume, as the 200-server example shows.

Is there a cloud security checklist, and what is a cloud security scanner?

A tool that checks cloud settings or infrastructure code against rules. Checkov, which I used, scans Terraform files and found 33 failed checks in my insecure example.

Is the cloud less secure than on-premises systems?

It depends on how you use it. Providers secure the infrastructure at large scale, but customer misconfiguration and weak access control can expose data in any environment.

What are the NCSC cloud security principles?

Fourteen principles for assessing cloud services, from data in transit protection to secure use of the service. The last one is the customer's own responsibility.

What are cloud security basics for a small business?

Turn on multi-factor sign-in, keep data stores private, encrypt data, enable logging, keep software updated and test your backups.

How do I secure an AWS account?

Protect the root account, require multi-factor sign-in, use least privilege roles, block public access to storage, turn on logging and scan your configuration.

Does a scanner replace a security review?

No. A scanner checks what its rules cover. My test showed it missed a hard-coded password until I ran a separate secrets mode.

A quick checklist

Up nextzero-day vulnerability guideCloud security depends on controlling access and on fixing known flaws quickly. Read our zero-day vulnerability guide for exposure and patching models, and our guide to MFA methods for hardening sign-in.

From circuittimes.com/security/cloud-security-fundamentals/

Was this guide helpful?

Keep going

More in Threats & Malware

See all

The briefing, without the noise.

The stories that matter in technology, every weekday morning.

Free. Unsubscribe in one click.