Cloud security

Use when assessing cloud infrastructure for security misconfigurations, IAM privilege escalation paths, S3 public exposure, open security group rules, or IaC security gaps.

How to use it

Claude Code
  1. Run the line below. It pulls the whole folder into ~/.claude/skills/cloud-security, including the files SKILL.md points to.
  2. Describe your job in plain words. Claude Code follows the skill from there.
Claude Code — installs the whole folder, not just SKILL.md
npx degit alirezarezvani/claude-skills/engineering-team/skills/cloud-security#main ~/.claude/skills/cloud-security

For one project only, change the path to .claude/skills/cloud-security. This skill also uses cloud_posture_check.py, policy.json, bucket_config.json, sg.json, config.json, acl.json — copying SKILL.md alone won't be enough. See the folder on GitHub.

Claude (web or desktop app)
  1. On this page open ⋯ → Download .md.
  2. Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
  3. Pick the file and Save. Claude shows the name and description and runs a security scan.
  4. Check the skill is switched on.
  5. Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
  1. ChatGPT: make a Project and paste it into Instructions.
  2. Neither? Paste it at the top of a new chat — it works for that chat.
Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Source of Cloud security

Show the full text344 lines
namedescription
cloud-securityUse when assessing cloud infrastructure for security misconfigurations, IAM privilege escalation paths, S3 public exposure, open security group rules, or IaC security gaps. Covers AWS, Azure, and GCP posture assessment with MITRE ATT&CK mapping.

Cloud Security

Cloud security posture assessment skill for detecting IAM privilege escalation, public storage exposure, network configuration risks, and infrastructure-as-code misconfigurations. This is NOT incident response for active cloud compromise (see incident-response) or application vulnerability scanning (see security-pen-testing) — this is about systematic cloud configuration analysis to prevent exploitation.


Table of Contents


Overview

What This Skill Does

This skill provides the methodology and tooling for cloud security posture management (CSPM) — systematically checking cloud configurations for misconfigurations that create exploitable attack surface. It covers IAM privilege escalation paths, storage public exposure, network over-permissioning, and infrastructure code security.

Distinction from Other Security Skills
Skill Focus Approach
cloud-security (this) Cloud configuration risk Preventive — assess before exploitation
incident-response Active cloud incidents Reactive — triage confirmed cloud compromise
threat-detection Behavioral anomalies Proactive — hunt for attacker activity in cloud logs
security-pen-testing Application vulnerabilities Offensive — actively exploit found weaknesses
Prerequisites

Read access to IAM policy documents, S3 bucket configurations, and security group rules in JSON format. For continuous monitoring, integrate with cloud provider APIs (AWS Config, Azure Policy, GCP Security Command Center).


Cloud Posture Check Tool

The cloud_posture_check.py tool runs three types of checks: iam (privilege escalation), s3 (public access), and sg (network exposure). It auto-detects the check type from the config file structure or accepts explicit --check flags.

# Analyze an IAM policy for privilege escalation paths
python3 scripts/cloud_posture_check.py policy.json --check iam --json

# Assess S3 bucket configuration for public access
python3 scripts/cloud_posture_check.py bucket_config.json --check s3 --json

# Check security group rules for open admin ports
python3 scripts/cloud_posture_check.py sg.json --check sg --json

# Run all checks with internet-facing severity bump
python3 scripts/cloud_posture_check.py config.json --check all \
  --provider aws --severity-modifier internet-facing --json

# Regulated data context (bumps severity by one level for all findings)
python3 scripts/cloud_posture_check.py config.json --check all \
  --severity-modifier regulated-data --json

# Pipe IAM policy from AWS CLI
aws iam get-policy-version --policy-arn arn:aws:iam::123456789012:policy/MyPolicy \
  --version-id v1 | jq '.PolicyVersion.Document' | \
  python3 scripts/cloud_posture_check.py - --check iam --json
Exit Codes
Code Meaning Required Action
0 No high/critical findings No action required
1 High-severity findings Remediate within 24 hours
2 Critical findings Remediate immediately — escalate to incident-response if active

IAM Policy Analysis

IAM analysis detects privilege escalation paths, overprivileged grants, public principal exposure, and data exfiltration risk.

Privilege Escalation Patterns
Pattern Severity Key Action Combination MITRE
Lambda PassRole escalation Critical iam:PassRole + lambda:CreateFunction T1078.004
EC2 instance profile abuse Critical iam:PassRole + ec2:RunInstances T1078.004
CloudFormation PassRole Critical iam:PassRole + cloudformation:CreateStack T1078.004
Self-attach policy escalation Critical iam:AttachUserPolicy + sts:GetCallerIdentity T1484.001
Inline policy self-escalation Critical iam:PutUserPolicy + sts:GetCallerIdentity T1484.001
Policy version backdoor Critical iam:CreatePolicyVersion + iam:ListPolicies T1484.001
Credential harvesting High iam:CreateAccessKey + iam:ListUsers T1098.001
Group membership escalation High iam:AddUserToGroup + iam:ListGroups T1098
Password reset attack High iam:UpdateLoginProfile + iam:ListUsers T1098
Service-level wildcard High iam:* or s3:* or ec2:* T1078.004
IAM Finding Severity Guide
Finding Type Condition Severity
Full admin wildcard Action=* Resource=* Critical
Public principal Principal: '*' Critical
Dangerous action combo Two-action escalation path Critical
Individual priv-esc actions On wildcard resource High
Data exfiltration actions s3:GetObject, secretsmanager:GetSecretValue on * High
Service wildcard service:* action High
Data actions on named resource Appropriate scope Low/Clean
Least Privilege Recommendations

For every critical or high finding, the tool outputs a least_privilege_suggestion field with specific remediation guidance:

  • Replace Action: * with a named list of required actions
  • Replace Resource: * with specific ARN patterns
  • Use AWS Access Analyzer to identify actually-used permissions
  • Separate dangerous action combinations into different roles with distinct trust policies

S3 Exposure Assessment

S3 assessment checks four dimensions: public access block configuration, bucket ACL, bucket policy principal exposure, and default encryption.

S3 Configuration Check Matrix
Check Finding Condition Severity
Public access block Any of four flags missing/false High
Bucket ACL public-read-write Critical
Bucket ACL public-read or authenticated-read High
Bucket policy Principal "Principal": "*" with Allow Critical
Default encryption No ServerSideEncryptionConfiguration High
Default encryption Non-standard SSEAlgorithm Medium
No PublicAccessBlockConfiguration Status unknown Medium
{
  "PublicAccessBlockConfiguration": {
    "BlockPublicAcls": true,
    "BlockPublicPolicy": true,
    "IgnorePublicAcls": true,
    "RestrictPublicBuckets": true
  },
  "ServerSideEncryptionConfiguration": {
    "Rules": [{
      "ApplyServerSideEncryptionByDefault": {
        "SSEAlgorithm": "aws:kms",
        "KMSMasterKeyID": "arn:aws:kms:region:account:key/key-id"
      },
      "BucketKeyEnabled": true
    }]
  },
  "ACL": "private"
}

All four public access block settings must be enabled at both the bucket level and the AWS account level. Account-level settings can be overridden by bucket-level settings if not both enforced.


Security Group Analysis

Security group analysis flags inbound rules that expose admin ports, database ports, or all traffic to internet CIDRs (0.0.0.0/0, ::/0).

Critical Port Exposure Rules
Port Service Finding Severity Remediation
22 SSH Critical Restrict to VPN CIDR or use AWS Systems Manager Session Manager
3389 RDP Critical Restrict to VPN CIDR or use AWS Fleet Manager
0–65535 (all) All traffic Critical Remove rule; add specific required ports only
High-Risk Database Port Rules
Port Service Finding Severity Remediation
1433 MSSQL High Allow from application tier SG only — move to private subnet
3306 MySQL High Allow from application tier SG only — move to private subnet
5432 PostgreSQL High Allow from application tier SG only — move to private subnet
27017 MongoDB High Allow from application tier SG only — move to private subnet
6379 Redis High Allow from application tier SG only — move to private subnet
9200 Elasticsearch High Allow from application tier SG only — move to private subnet
Severity Modifiers

Use --severity-modifier internet-facing when the assessed resource is directly internet-accessible (load balancer, API gateway, public EC2). Use --severity-modifier regulated-data when the resource handles PCI, HIPAA, or GDPR-regulated data. Both modifiers bump each finding's severity by one level.


IaC Security Review

Infrastructure-as-code review catches configuration issues at definition time, before deployment.

IaC Check Matrix
Tool Check Types When to Run
Terraform Resource-level checks (aws_s3_bucket_acl, aws_security_group, aws_iam_policy_document) Pre-plan, pre-apply, PR gate
CloudFormation Template property validation (PublicAccessBlockConfiguration, SecurityGroupIngress) Template lint, deploy gate
Kubernetes manifests Container privileges, network policies, secret exposure PR gate, admission controller
Helm charts Same as Kubernetes PR gate
Terraform IAM Policy Example — Finding vs. Clean
# BAD: Will generate critical findings
resource "aws_iam_policy" "bad_policy" {
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect   = "Allow"
      Action   = "*"
      Resource = "*"
    }]
  })
}

# GOOD: Least privilege
resource "aws_iam_policy" "good_policy" {
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect   = "Allow"
      Action   = ["s3:GetObject", "s3:PutObject"]
      Resource = "arn:aws:s3:::my-specific-bucket/*"
    }]
  })
}

Full CSPM check reference: references/cspm-checks.md


Cloud Provider Coverage Matrix

Check Type AWS Azure GCP
IAM privilege escalation Full (IAM policies, trust policies, ESCALATION_COMBOS) Partial (RBAC assignments, service principal risks) Partial (IAM bindings, workload identity)
Storage public access Full (S3 bucket policies, ACLs, public access block) Partial (Blob SAS tokens, container access levels) Partial (GCS bucket IAM, uniform bucket-level access)
Network exposure Full (Security Groups, NACLs, port-level analysis) Partial (NSG rules, inbound port analysis) Partial (Firewall rules, VPC firewall)
IaC scanning Full (Terraform, CloudFormation) Partial (ARM templates, Bicep) Partial (Deployment Manager)

Workflows

Workflow 1: Quick Posture Check (20 Minutes)

For a newly provisioned resource or pre-deployment review:

# 1. Export IAM policy document
aws iam get-policy-version --policy-arn ARN --version-id v1 | \
  jq '.PolicyVersion.Document' > policy.json
python3 scripts/cloud_posture_check.py policy.json --check iam --json

# 2. Check S3 bucket configuration
aws s3api get-bucket-acl --bucket my-bucket > acl.json
aws s3api get-public-access-block --bucket my-bucket >> bucket.json
python3 scripts/cloud_posture_check.py bucket.json --check s3 --json

# 3. Review security groups for open admin ports
aws ec2 describe-security-groups --group-ids sg-123456 | \
  jq '.SecurityGroups[0]' > sg.json
python3 scripts/cloud_posture_check.py sg.json --check sg --json

Decision: Exit code 2 = block deployment and remediate. Exit code 1 = schedule remediation within 24 hours.

Workflow 2: Full Cloud Security Assessment (Multi-Day)

Day 1 — IAM and Identity:

  1. Export all IAM policies attached to production roles
  2. Run cloud_posture_check.py --check iam on each policy
  3. Map all privilege escalation paths found
  4. Identify overprivileged service accounts and roles
  5. Review cross-account trust policies

Day 2 — Storage and Network:

  1. Enumerate all S3 buckets and export configurations
  2. Run cloud_posture_check.py --check s3 --severity-modifier regulated-data for data buckets
  3. Export security group configurations for all VPCs
  4. Run cloud_posture_check.py --check sg for internet-facing resources
  5. Review NACL rules for network segmentation gaps

Day 3 — IaC and Continuous Integration:

  1. Review Terraform/CloudFormation templates in version control
  2. Check CI/CD pipeline for IaC security gates
  3. Validate findings against references/cspm-checks.md
  4. Produce remediation plan with priority ordering (Critical → High → Medium)
Workflow 3: CI/CD Security Gate

Integrate posture checks into deployment pipelines to prevent misconfigured resources reaching production:

# Validate IaC before terraform apply
terraform show -json plan.json | \
  jq '[.resource_changes[].change.after | select(. != null)]' > resources.json
python3 scripts/cloud_posture_check.py resources.json --check all --json
if [ $? -eq 2 ]; then
  echo "Critical cloud security findings — blocking deployment"
  exit 1
fi

# Validate existing S3 bucket before modifying
aws s3api get-bucket-policy --bucket "${BUCKET}" | jq '.Policy | fromjson' | \
  python3 scripts/cloud_posture_check.py - --check s3 \
  --severity-modifier regulated-data --json

Anti-Patterns

  1. Running IAM analysis without checking escalation combos — Individual high-risk actions in isolation may appear low-risk. The danger is in combinations: iam:PassRole alone is not critical, but iam:PassRole + lambda:CreateFunction is a confirmed privilege escalation path. Always analyze the full statement, not individual actions.
  2. Enabling only bucket-level public access block — AWS S3 has both account-level and bucket-level public access block settings. A bucket-level setting can override an account-level setting. Both must be configured. Account-level block alone is insufficient if any bucket has explicit overrides.
  3. Treating --severity-modifier internet-facing as optional for public resources — Internet-facing resources have significantly higher exposure than internal resources. High findings on internet-facing infrastructure should be treated as critical. Always apply --severity-modifier internet-facing for DMZ, load balancer, and API gateway configurations.
  4. Checking only administrator policies — Privilege escalation paths frequently originate from non-administrator policies that combine innocuous-looking permissions. All policies attached to production identities must be checked, not just policies with obvious elevated access.
  5. Remediating findings without root cause analysis — Removing a dangerous permission without understanding why it was granted will result in re-addition. Document the business justification for every high-risk permission before removing it, to prevent silent re-introduction.
  6. Ignoring service account over-permissioning — Service accounts are often over-provisioned during development and never trimmed for production. Every service account in production must be audited against AWS Access Analyzer or equivalent to identify and remove unused permissions.
  7. Not applying severity modifiers for regulated data workloads — A high finding in a general-purpose S3 bucket is different from the same finding in a bucket containing PHI or cardholder data. Always use --severity-modifier regulated-data when assessing resources in regulated data environments.

Cross-References

Skill Relationship
incident-response Critical findings (public S3, privilege escalation confirmed active) may trigger incident classification
threat-detection Cloud posture findings create hunting targets — over-permissioned roles are likely lateral movement destinations
red-team Red team exercises specifically test exploitability of cloud misconfigurations found in posture assessment
security-pen-testing Cloud posture findings feed into the infrastructure security section of pen test assessments
1---
2name: "cloud-security"
3description: "Use when assessing cloud infrastructure for security misconfigurations, IAM privilege escalation paths, S3 public exposure, open security group rules, or IaC security gaps. Covers AWS, Azure, and GCP posture assessment with MITRE ATT&CK mapping."
4---
5 
6# Cloud Security
7 
8Cloud security posture assessment skill for detecting IAM privilege escalation, public storage exposure, network configuration risks, and infrastructure-as-code misconfigurations. This is NOT incident response for active cloud compromise (see incident-response) or application vulnerability scanning (see security-pen-testing) — this is about systematic cloud configuration analysis to prevent exploitation.
9 
10---
11 
12## Table of Contents
13 
14- [Overview](#overview)
15- [Cloud Posture Check Tool](#cloud-posture-check-tool)
16- [IAM Policy Analysis](#iam-policy-analysis)
17- [S3 Exposure Assessment](#s3-exposure-assessment)
18- [Security Group Analysis](#security-group-analysis)
19- [IaC Security Review](#iac-security-review)
20- [Cloud Provider Coverage Matrix](#cloud-provider-coverage-matrix)
21- [Workflows](#workflows)
22- [Anti-Patterns](#anti-patterns)
23- [Cross-References](#cross-references)
24 
25---
26 
27## Overview
28 
29### What This Skill Does
30 
31This skill provides the methodology and tooling for **cloud security posture management (CSPM)** — systematically checking cloud configurations for misconfigurations that create exploitable attack surface. It covers IAM privilege escalation paths, storage public exposure, network over-permissioning, and infrastructure code security.
32 
33### Distinction from Other Security Skills
34 
35| Skill | Focus | Approach |
36|-------|-------|----------|
37| **cloud-security** (this) | Cloud configuration risk | Preventive — assess before exploitation |
38| incident-response | Active cloud incidents | Reactive — triage confirmed cloud compromise |
39| threat-detection | Behavioral anomalies | Proactive — hunt for attacker activity in cloud logs |
40| security-pen-testing | Application vulnerabilities | Offensive — actively exploit found weaknesses |
41 
42### Prerequisites
43 
44Read access to IAM policy documents, S3 bucket configurations, and security group rules in JSON format. For continuous monitoring, integrate with cloud provider APIs (AWS Config, Azure Policy, GCP Security Command Center).
45 
46---
47 
48## Cloud Posture Check Tool
49 
50The `cloud_posture_check.py` tool runs three types of checks: `iam` (privilege escalation), `s3` (public access), and `sg` (network exposure). It auto-detects the check type from the config file structure or accepts explicit `--check` flags.
51 
52```bash
53# Analyze an IAM policy for privilege escalation paths
54python3 scripts/cloud_posture_check.py policy.json --check iam --json
55 
56# Assess S3 bucket configuration for public access
57python3 scripts/cloud_posture_check.py bucket_config.json --check s3 --json
58 
59# Check security group rules for open admin ports
60python3 scripts/cloud_posture_check.py sg.json --check sg --json
61 
62# Run all checks with internet-facing severity bump
63python3 scripts/cloud_posture_check.py config.json --check all \
64 --provider aws --severity-modifier internet-facing --json
65 
66# Regulated data context (bumps severity by one level for all findings)
67python3 scripts/cloud_posture_check.py config.json --check all \
68 --severity-modifier regulated-data --json
69 
70# Pipe IAM policy from AWS CLI
71aws iam get-policy-version --policy-arn arn:aws:iam::123456789012:policy/MyPolicy \
72 --version-id v1 | jq '.PolicyVersion.Document' | \
73 python3 scripts/cloud_posture_check.py - --check iam --json
74```
75 
76### Exit Codes
77 
78| Code | Meaning | Required Action |
79|------|---------|-----------------|
80| 0 | No high/critical findings | No action required |
81| 1 | High-severity findings | Remediate within 24 hours |
82| 2 | Critical findings | Remediate immediately — escalate to incident-response if active |
83 
84---
85 
86## IAM Policy Analysis
87 
88IAM analysis detects privilege escalation paths, overprivileged grants, public principal exposure, and data exfiltration risk.
89 
90### Privilege Escalation Patterns
91 
92| Pattern | Severity | Key Action Combination | MITRE |
93|---------|----------|------------------------|-------|
94| Lambda PassRole escalation | Critical | iam:PassRole + lambda:CreateFunction | T1078.004 |
95| EC2 instance profile abuse | Critical | iam:PassRole + ec2:RunInstances | T1078.004 |
96| CloudFormation PassRole | Critical | iam:PassRole + cloudformation:CreateStack | T1078.004 |
97| Self-attach policy escalation | Critical | iam:AttachUserPolicy + sts:GetCallerIdentity | T1484.001 |
98| Inline policy self-escalation | Critical | iam:PutUserPolicy + sts:GetCallerIdentity | T1484.001 |
99| Policy version backdoor | Critical | iam:CreatePolicyVersion + iam:ListPolicies | T1484.001 |
100| Credential harvesting | High | iam:CreateAccessKey + iam:ListUsers | T1098.001 |
101| Group membership escalation | High | iam:AddUserToGroup + iam:ListGroups | T1098 |
102| Password reset attack | High | iam:UpdateLoginProfile + iam:ListUsers | T1098 |
103| Service-level wildcard | High | iam:* or s3:* or ec2:* | T1078.004 |
104 
105### IAM Finding Severity Guide
106 
107| Finding Type | Condition | Severity |
108|-------------|-----------|----------|
109| Full admin wildcard | Action=* Resource=* | Critical |
110| Public principal | Principal: '*' | Critical |
111| Dangerous action combo | Two-action escalation path | Critical |
112| Individual priv-esc actions | On wildcard resource | High |
113| Data exfiltration actions | s3:GetObject, secretsmanager:GetSecretValue on * | High |
114| Service wildcard | service:* action | High |
115| Data actions on named resource | Appropriate scope | Low/Clean |
116 
117### Least Privilege Recommendations
118 
119For every critical or high finding, the tool outputs a `least_privilege_suggestion` field with specific remediation guidance:
120- Replace `Action: *` with a named list of required actions
121- Replace `Resource: *` with specific ARN patterns
122- Use AWS Access Analyzer to identify actually-used permissions
123- Separate dangerous action combinations into different roles with distinct trust policies
124 
125---
126 
127## S3 Exposure Assessment
128 
129S3 assessment checks four dimensions: public access block configuration, bucket ACL, bucket policy principal exposure, and default encryption.
130 
131### S3 Configuration Check Matrix
132 
133| Check | Finding Condition | Severity |
134|-------|------------------|----------|
135| Public access block | Any of four flags missing/false | High |
136| Bucket ACL | public-read-write | Critical |
137| Bucket ACL | public-read or authenticated-read | High |
138| Bucket policy Principal | "Principal": "*" with Allow | Critical |
139| Default encryption | No ServerSideEncryptionConfiguration | High |
140| Default encryption | Non-standard SSEAlgorithm | Medium |
141| No PublicAccessBlockConfiguration | Status unknown | Medium |
142 
143### Recommended S3 Baseline Configuration
144 
145```json
146{
147 "PublicAccessBlockConfiguration": {
148 "BlockPublicAcls": true,
149 "BlockPublicPolicy": true,
150 "IgnorePublicAcls": true,
151 "RestrictPublicBuckets": true
152 },
153 "ServerSideEncryptionConfiguration": {
154 "Rules": [{
155 "ApplyServerSideEncryptionByDefault": {
156 "SSEAlgorithm": "aws:kms",
157 "KMSMasterKeyID": "arn:aws:kms:region:account:key/key-id"
158 },
159 "BucketKeyEnabled": true
160 }]
161 },
162 "ACL": "private"
163}
164```
165 
166All four public access block settings must be enabled at both the bucket level and the AWS account level. Account-level settings can be overridden by bucket-level settings if not both enforced.
167 
168---
169 
170## Security Group Analysis
171 
172Security group analysis flags inbound rules that expose admin ports, database ports, or all traffic to internet CIDRs (0.0.0.0/0, ::/0).
173 
174### Critical Port Exposure Rules
175 
176| Port | Service | Finding Severity | Remediation |
177|------|---------|-----------------|-------------|
178| 22 | SSH | Critical | Restrict to VPN CIDR or use AWS Systems Manager Session Manager |
179| 3389 | RDP | Critical | Restrict to VPN CIDR or use AWS Fleet Manager |
180| 0–65535 (all) | All traffic | Critical | Remove rule; add specific required ports only |
181 
182### High-Risk Database Port Rules
183 
184| Port | Service | Finding Severity | Remediation |
185|------|---------|-----------------|-------------|
186| 1433 | MSSQL | High | Allow from application tier SG only — move to private subnet |
187| 3306 | MySQL | High | Allow from application tier SG only — move to private subnet |
188| 5432 | PostgreSQL | High | Allow from application tier SG only — move to private subnet |
189| 27017 | MongoDB | High | Allow from application tier SG only — move to private subnet |
190| 6379 | Redis | High | Allow from application tier SG only — move to private subnet |
191| 9200 | Elasticsearch | High | Allow from application tier SG only — move to private subnet |
192 
193### Severity Modifiers
194 
195Use `--severity-modifier internet-facing` when the assessed resource is directly internet-accessible (load balancer, API gateway, public EC2). Use `--severity-modifier regulated-data` when the resource handles PCI, HIPAA, or GDPR-regulated data. Both modifiers bump each finding's severity by one level.
196 
197---
198 
199## IaC Security Review
200 
201Infrastructure-as-code review catches configuration issues at definition time, before deployment.
202 
203### IaC Check Matrix
204 
205| Tool | Check Types | When to Run |
206|------|-------------|-------------|
207| Terraform | Resource-level checks (aws_s3_bucket_acl, aws_security_group, aws_iam_policy_document) | Pre-plan, pre-apply, PR gate |
208| CloudFormation | Template property validation (PublicAccessBlockConfiguration, SecurityGroupIngress) | Template lint, deploy gate |
209| Kubernetes manifests | Container privileges, network policies, secret exposure | PR gate, admission controller |
210| Helm charts | Same as Kubernetes | PR gate |
211 
212### Terraform IAM Policy Example — Finding vs. Clean
213 
214```hcl
215# BAD: Will generate critical findings
216resource "aws_iam_policy" "bad_policy" {
217 policy = jsonencode({
218 Version = "2012-10-17"
219 Statement = [{
220 Effect = "Allow"
221 Action = "*"
222 Resource = "*"
223 }]
224 })
225}
226 
227# GOOD: Least privilege
228resource "aws_iam_policy" "good_policy" {
229 policy = jsonencode({
230 Version = "2012-10-17"
231 Statement = [{
232 Effect = "Allow"
233 Action = ["s3:GetObject", "s3:PutObject"]
234 Resource = "arn:aws:s3:::my-specific-bucket/*"
235 }]
236 })
237}
238```
239 
240Full CSPM check reference: `references/cspm-checks.md`
241 
242---
243 
244## Cloud Provider Coverage Matrix
245 
246| Check Type | AWS | Azure | GCP |
247|-----------|-----|-------|-----|
248| IAM privilege escalation | Full (IAM policies, trust policies, ESCALATION_COMBOS) | Partial (RBAC assignments, service principal risks) | Partial (IAM bindings, workload identity) |
249| Storage public access | Full (S3 bucket policies, ACLs, public access block) | Partial (Blob SAS tokens, container access levels) | Partial (GCS bucket IAM, uniform bucket-level access) |
250| Network exposure | Full (Security Groups, NACLs, port-level analysis) | Partial (NSG rules, inbound port analysis) | Partial (Firewall rules, VPC firewall) |
251| IaC scanning | Full (Terraform, CloudFormation) | Partial (ARM templates, Bicep) | Partial (Deployment Manager) |
252 
253---
254 
255## Workflows
256 
257### Workflow 1: Quick Posture Check (20 Minutes)
258 
259For a newly provisioned resource or pre-deployment review:
260 
261```bash
262# 1. Export IAM policy document
263aws iam get-policy-version --policy-arn ARN --version-id v1 | \
264 jq '.PolicyVersion.Document' > policy.json
265python3 scripts/cloud_posture_check.py policy.json --check iam --json
266 
267# 2. Check S3 bucket configuration
268aws s3api get-bucket-acl --bucket my-bucket > acl.json
269aws s3api get-public-access-block --bucket my-bucket >> bucket.json
270python3 scripts/cloud_posture_check.py bucket.json --check s3 --json
271 
272# 3. Review security groups for open admin ports
273aws ec2 describe-security-groups --group-ids sg-123456 | \
274 jq '.SecurityGroups[0]' > sg.json
275python3 scripts/cloud_posture_check.py sg.json --check sg --json
276```
277 
278**Decision**: Exit code 2 = block deployment and remediate. Exit code 1 = schedule remediation within 24 hours.
279 
280### Workflow 2: Full Cloud Security Assessment (Multi-Day)
281 
282**Day 1 — IAM and Identity:**
2831. Export all IAM policies attached to production roles
2842. Run cloud_posture_check.py --check iam on each policy
2853. Map all privilege escalation paths found
2864. Identify overprivileged service accounts and roles
2875. Review cross-account trust policies
288 
289**Day 2 — Storage and Network:**
2901. Enumerate all S3 buckets and export configurations
2912. Run cloud_posture_check.py --check s3 --severity-modifier regulated-data for data buckets
2923. Export security group configurations for all VPCs
2934. Run cloud_posture_check.py --check sg for internet-facing resources
2945. Review NACL rules for network segmentation gaps
295 
296**Day 3 — IaC and Continuous Integration:**
2971. Review Terraform/CloudFormation templates in version control
2982. Check CI/CD pipeline for IaC security gates
2993. Validate findings against `references/cspm-checks.md`
3004. Produce remediation plan with priority ordering (Critical → High → Medium)
301 
302### Workflow 3: CI/CD Security Gate
303 
304Integrate posture checks into deployment pipelines to prevent misconfigured resources reaching production:
305 
306```bash
307# Validate IaC before terraform apply
308terraform show -json plan.json | \
309 jq '[.resource_changes[].change.after | select(. != null)]' > resources.json
310python3 scripts/cloud_posture_check.py resources.json --check all --json
311if [ $? -eq 2 ]; then
312 echo "Critical cloud security findings — blocking deployment"
313 exit 1
314fi
315 
316# Validate existing S3 bucket before modifying
317aws s3api get-bucket-policy --bucket "${BUCKET}" | jq '.Policy | fromjson' | \
318 python3 scripts/cloud_posture_check.py - --check s3 \
319 --severity-modifier regulated-data --json
320```
321 
322---
323 
324## Anti-Patterns
325 
3261. **Running IAM analysis without checking escalation combos** — Individual high-risk actions in isolation may appear low-risk. The danger is in combinations: `iam:PassRole` alone is not critical, but `iam:PassRole + lambda:CreateFunction` is a confirmed privilege escalation path. Always analyze the full statement, not individual actions.
3272. **Enabling only bucket-level public access block** — AWS S3 has both account-level and bucket-level public access block settings. A bucket-level setting can override an account-level setting. Both must be configured. Account-level block alone is insufficient if any bucket has explicit overrides.
3283. **Treating `--severity-modifier internet-facing` as optional for public resources** — Internet-facing resources have significantly higher exposure than internal resources. High findings on internet-facing infrastructure should be treated as critical. Always apply `--severity-modifier internet-facing` for DMZ, load balancer, and API gateway configurations.
3294. **Checking only administrator policies** — Privilege escalation paths frequently originate from non-administrator policies that combine innocuous-looking permissions. All policies attached to production identities must be checked, not just policies with obvious elevated access.
3305. **Remediating findings without root cause analysis** — Removing a dangerous permission without understanding why it was granted will result in re-addition. Document the business justification for every high-risk permission before removing it, to prevent silent re-introduction.
3316. **Ignoring service account over-permissioning** — Service accounts are often over-provisioned during development and never trimmed for production. Every service account in production must be audited against AWS Access Analyzer or equivalent to identify and remove unused permissions.
3327. **Not applying severity modifiers for regulated data workloads** — A high finding in a general-purpose S3 bucket is different from the same finding in a bucket containing PHI or cardholder data. Always use `--severity-modifier regulated-data` when assessing resources in regulated data environments.
333 
334---
335 
336## Cross-References
337 
338| Skill | Relationship |
339|-------|-------------|
340| [incident-response](../incident-response/SKILL.md) | Critical findings (public S3, privilege escalation confirmed active) may trigger incident classification |
341| [threat-detection](../threat-detection/SKILL.md) | Cloud posture findings create hunting targets — over-permissioned roles are likely lateral movement destinations |
342| [red-team](../red-team/SKILL.md) | Red team exercises specifically test exploitability of cloud misconfigurations found in posture assessment |
343| [security-pen-testing](../security-pen-testing/SKILL.md) | Cloud posture findings feed into the infrastructure security section of pen test assessments |
344 

Discussion

Alternatives

Also in SecuritySee all 533 in Development →