# Cloud Security Fundamentals: Protecting Infrastructure, Data and Access in the Cloud

Organisations typically utilise cloud computing to run applications, databases and storage.

Cloud platforms allow for quick and scalable deployment of infrastructure, as well as managed services, in minutes.

Startups can quickly deploy a production ready application with managed databases, object storage and serverless functions, without any physical hardware.

However, due to the speed and flexibility of cloud platforms there are many opportunities for accidental configuration errors. This can include open storage buckets, excessive permissions, and open management interfaces.

## Cloud Security

Cloud Security is implemented through a mixture of policies, configurations, identity access controls and monitoring to ensure that cloud systems, applications and data are secure.

This includes:

* Limiting identities and service accounts to only have necessary permissions.
* Avoiding accidental public exposure of storage buckets and databases.
* Segregating network traffic between different cloud resources and encrypting it.
* Having auditable and repeatable changes to infrastructure.
* Detecting threats and abnormal API calls quickly.

Cloud security is largely based around configuration and identity rather than physical security.

## Why is Cloud Security Important?

Cloud accounts can contain extremely valuable assets for an organisation. These can include customer data, backups, source code and encryption keys.

If a configuration error occurs within a cloud account, this could lead to millions of records being exposed or expensive resources being spun up by attackers.

Common risks include:

* **Data exposure in public** (Misconfigured storage buckets and database snapshots).
* **Over Privileged Identities** (Compromised API keys or roles with excessive privileges).
* **Account takeover** (Root/administrator accounts without MFA).
* **Lateral Movement** (Flat network architecture meaning that an attacker can move from one compromised container to backend databases).
* **Resource Abuse** (Compute resources being used for crypto mining or external attacks).

Understanding the responsibilities of cloud security is key to preventing these issues in the first place.

## Common Issues

### 3.1 Excessive IAM Permissions

IAM is used to manage access to resources in a cloud account.

If users or roles are given wild card permissions (eg. `:`), then if credentials are leaked, the entire environment may be compromised.

**Prevention:**

* Give users/roles only the minimum permissions required to complete their tasks.
* Give temporary permissions using IAM roles, rather than long term static keys.
* Do not use the root account for normal operations.
* Regularly check for and remove unused users, roles and keys.

### 3.2 Exposed Data in Storage and Databases

If access blocks are not configured properly, data stored in object storage and databases may be exposed to the public.

**Prevention:**

* Ensure that public access blocks are set on storage by default.
* Place databases in private subnets without public IP addresses.
* Ensure authentication and encryption is required to access each storage bucket and database.
* Use automated scanners to alert if a resource becomes readable by the public.

### 3.3 Hardcoded credentials

Sometimes developers will include credentials to access cloud services or databases in git repos or containers. As bots continually scan public repos, keys may be exploited within minutes.

**Prevention:**

* Store credentials in secret management systems rather than code/config files.
* Set pre commit checks and scan repos to prevent accidental pushes.
* Immediately rotate exposed keys and check activity logs in the cloud for unauthorised activity.

### 3.4 Poor Network Segregation

If VMs, containers and databases are all in the same network, and one part of this network is compromised, the damage could be catastrophic.

**Prevention:**

* Segregate public load balancers from application and database layers.
* Strictly limit the ports allowed in security groups/firewalls and sources allowed.
* Use private endpoints to connect to managed services.

### 3.5 No Logging

Without centralised logging, it may be difficult to determine how an attacker accessed the system or which resources were modified.

**Prevention:**

* Enable logging across all regions in the cloud (CloudTrail/Activity Logs).
* Store logs in a secure central location with limited access.
* Set alerts for high risk activity (Disabling logging, creating admin roles, opening firewall ports).

## Shared Responsibility Model

Cloud security operates under a Shared Responsibility Model.

### Security OF the cloud (Responsibility of cloud provider)

* Secure data centres and hardware
* Hypervisors, networking and storage infrastructure
* Availability of managed services.

### Security IN the cloud (Responsibility of customer)

* Identity and Access Management (User, roles, MFA, policies)
* Configuration of storage, databases, firewalls and compute resources.
* Application code, OS updates (VMs), and encryption of sensitive data.

Understanding what is the responsibility of the cloud provider and what is your responsibility will prevent dangerous assumptions.

## Best Practice

To improve security in cloud environments:

* **Secure root account:** Enable MFA (Hardware or application) and secure root credentials.
* **Infrastructure as Code:** Use Terraform or CloudFormation to define infrastructure. This ensures changes are reviewed and repeatable.
* **Encrypt data:** Enable encryption at rest for disks, backups and storage, and enforce TLS in transit.
* **Short lived credentials:** Use SSO and temporary role assumption rather than static keys.
* **Segregate environments:** Store development, staging and production workloads in separate accounts/subscriptions.
* **Posture management:** Use CSPM tools to detect misconfigurations and drift.

## Testing

Cloud security should be validated both before and after deployment.

Check IaC templates for misconfigurations. Ensure:

* IAM policies do not allow excessive permissions or unused roles.
* Storage buckets and database snapshots are not publicly accessible.
* Test alerts for incident responses by creating unauthorised configuration changes in a sandbox account.

Always test in environments you own/are permitted to test in.

## Industry Standards

There are several frameworks to follow to improve security in cloud environments.

* **OWASP Cloud-Native Application Security Top 10:** Includes insecure configurations, authentication issues, CI/CD issues and over privileged workloads.
* **CIS Cloud Benchmarks:** Detailed guidance on hardening AWS, Microsoft Azure and Google Cloud.
* **Cloud Security Alliance (CSA) Cloud Controls Matrix:** Defines security controls in different areas of the cloud.

Following industry standards means engineering teams have clear benchmarks to aim for.

## Future of Cloud Security

With increasing use of containers, serverless and multi-cloud solutions, cloud infrastructure is becoming increasingly dynamic.

New areas of focus include:

* **Identity centric security:** Using IAM as the main security control.
* **Policy as Code:** Blocking non-compliant infrastructure changes in CI/CD pipelines.
* **Runtime security:** Detecting anomalous behaviour in containers and memory exploitation.
* **Automated remediation:** Self healing controls to fix public storage and open security groups.

As complexity increases in cloud environments, automation and strong identity management is key.

## Summary

Cloud platforms provide great speed and scalability. However, systems may be exposed if permissions are incorrect, storage is open or keys are leaked.

By understanding the Shared Responsibility Model, limiting identity permissions, encrypting data and automating configuration checks, secure and robust infrastructure can be created in cloud environments.

## References

* [OWASP Cloud-Native Application Security](https://owasp.org/www-project-cloud-native-application-security-top-10/)
* [CIS Benchmarks](https://www.cisecurity.org/cis-benchmarks)
* [Cloud Security Alliance](https://cloudsecurityalliance.org/)
