Implementing Cloud Vulnerability Posture Management
Overview
Cloud Security Posture Management (CSPM) continuously monitors cloud infrastructure for misconfigurations, compliance violations, and security risks. Unlike traditional vulnerability scanning, CSPM focuses on cloud-native risks: IAM over-permissions, exposed storage buckets, unencrypted data, missing network controls, and service misconfigurations. This skill covers multi-cloud CSPM using AWS Security Hub, Azure Defender for Cloud, and open-source tools like Prowler and ScoutSuite.
When to Use
- When deploying or configuring implementing cloud vulnerability posture management capabilities in your environment
- When establishing security controls aligned to compliance requirements
- When building or improving security architecture for this domain
- When conducting security assessments that require this implementation
Prerequisites
AWS Security Hub
Enable Security Hub
# Enable AWS Security Hub with default standards
aws securityhub enable-security-hub \
--enable-default-standards \
--region us-east-1
# Enable specific standards
aws securityhub batch-enable-standards \
--standards-subscription-requests \
'{"StandardsArn":"arn:aws:securityhub:us-east-1::standards/aws-foundational-security-best-practices/v/1.0.0"}' \
'{"StandardsArn":"arn:aws:securityhub:us-east-1::standards/cis-aws-foundations-benchmark/v/1.4.0"}'
# Get findings summary
aws securityhub get-findings \
--filters '{"SeverityLabel":[{"Value":"CRITICAL","Comparison":"EQUALS"}],"RecordState":[{"Value":"ACTIVE","Comparison":"EQUALS"}]}' \
--max-items 10
Security Hub Standards
| Standard |
Description |
| AWS Foundational Security Best Practices |
AWS-recommended baseline controls |
| CIS AWS Foundations Benchmark 1.4 |
CIS hardening requirements |
| PCI DSS v3.2.1 |
Payment card industry controls |
| NIST SP 800-53 Rev 5 |
Federal security controls |
Azure Defender for Cloud
Enable Defender CSPM
# Enable Defender for Cloud free tier
az security pricing create \
--name CloudPosture \
--tier standard
# Check secure score
az security secure-score list \
--query "[].{Name:displayName,Score:current,Max:max}" \
--output table
# Get security recommendations
az security assessment list \
--query "[?status.code=='Unhealthy'].{Name:displayName,Severity:metadata.severity,Resource:resourceDetails.id}" \
--output table
# Get alerts
az security alert list \
--query "[?status=='Active'].{Name:alertDisplayName,Severity:severity,Time:timeGeneratedUtc}" \
--output table
Open-Source: Prowler
Installation and Execution
# Install Prowler
pip install prowler
# Run full AWS scan
prowler aws --output-formats json-ocsf,csv,html
# Run specific checks
prowler aws --checks s3_bucket_public_access iam_root_mfa_enabled ec2_sg_open_to_internet
# Run against specific AWS profile and region
prowler aws --profile production --region us-east-1 --output-formats json-ocsf
# Run CIS Benchmark compliance check
prowler aws --compliance cis_1.5_aws
# Run PCI DSS compliance
prowler aws --compliance pci_3.2.1_aws
# Scan Azure environment
prowler azure --subscription-ids "sub-id-here"
# Scan GCP environment
prowler gcp --project-ids "project-id-here"
Prowler Check Categories
| Category |
Examples |
| IAM |
Root MFA, password policy, access key rotation |
| S3 |
Public access, encryption, versioning |
| EC2 |
Security groups, EBS encryption, metadata service |
| RDS |
Public access, encryption, backup retention |
| CloudTrail |
Enabled, encrypted, log validation |
| VPC |
Flow logs, default SG restrictions |
| Lambda |
Public access, runtime versions |
| EKS |
Public endpoint, secrets encryption |
Open-Source: ScoutSuite
# Install ScoutSuite
pip install scoutsuite
# Run AWS assessment
scout aws --profile production
# Run Azure assessment
scout azure --cli
# Run GCP assessment
scout gcp --project-id my-project
# Results available as interactive HTML report
# Open scout-report/report.html in browser
Multi-Cloud Aggregation
import json
import subprocess
from datetime import datetime, timezone
def run_prowler_scan(provider, output_dir, compliance=None):
"""Run Prowler scan for a cloud provider."""
cmd = ["prowler", provider, "--output-formats", "json-ocsf",
"--output-directory", output_dir]
if compliance:
cmd.extend(["--compliance", compliance])
result = subprocess.run(cmd, capture_output=True, text=True, timeout=3600)
return result.returncode == 0
def aggregate_findings(prowler_dirs):
"""Aggregate findings from multiple Prowler scans."""
all_findings = []
for scan_dir in prowler_dirs:
json_files = list(Path(scan_dir).glob("*.json"))
for jf in json_files:
with open(jf, "r") as f:
for line in f:
try:
finding = json.loads(line.strip())
all_findings.append(finding)
except json.JSONDecodeError:
continue
# Sort by severity
severity_order = {"critical": 0, "high": 1, "medium": 2, "low": 3, "informational": 4}
all_findings.sort(key=lambda f: severity_order.get(
f.get("severity", "informational").lower(), 5
))
return all_findings
def generate_posture_report(findings, output_path):
"""Generate cloud security posture report."""
report = {
"generated_at": datetime.now(timezone.utc).isoformat(),
"total_findings": len(findings),
"by_severity": {},
"by_provider": {},
"by_service": {},
}
for f in findings:
sev = f.get("severity", "unknown")
provider = f.get("cloud_provider", "unknown")
service = f.get("service_name", "unknown")
report["by_severity"][sev] = report["by_severity"].get(sev, 0) + 1
report["by_provider"][provider] = report["by_provider"].get(provider, 0) + 1
report["by_service"][service] = report["by_service"].get(service, 0) + 1
with open(output_path, "w") as f:
json.dump(report, f, indent=2)
return report
References
1---2name: implementing-cloud-vulnerability-posture-management3description: Implement Cloud Security Posture Management using AWS Security Hub, Azure Defender for Cloud, and open-source tools like Prowler and ScoutSuite for multi-cloud vulnerability detection.4domain: cybersecurity5subdomain: vulnerability-management6tags: [cspm, cloud-security, aws-security-hub, azure-defender, prowler, scoutsuite, misconfiguration, cnapp]7version: "1.0"8author: mahipal9license: Apache-2.010metadata:11 source: https://skillmd.com/skills/micsapp/implementing-cloud-vulnerability-posture-management12---1314# Implementing Cloud Vulnerability Posture Management1516## Overview1718Cloud Security Posture Management (CSPM) continuously monitors cloud infrastructure for misconfigurations, compliance violations, and security risks. Unlike traditional vulnerability scanning, CSPM focuses on cloud-native risks: IAM over-permissions, exposed storage buckets, unencrypted data, missing network controls, and service misconfigurations. This skill covers multi-cloud CSPM using AWS Security Hub, Azure Defender for Cloud, and open-source tools like Prowler and ScoutSuite.192021## When to Use2223- When deploying or configuring implementing cloud vulnerability posture management capabilities in your environment24- When establishing security controls aligned to compliance requirements25- When building or improving security architecture for this domain26- When conducting security assessments that require this implementation2728## Prerequisites2930- AWS CLI configured with SecurityAudit IAM policy31- Azure CLI with Security Reader role32- Python 3.9+ with `boto3`, `azure-identity`, `azure-mgmt-security`33- Prowler (https://github.com/prowler-cloud/prowler)34- ScoutSuite (https://github.com/nccgroup/ScoutSuite)3536## AWS Security Hub3738### Enable Security Hub39```bash40# Enable AWS Security Hub with default standards41aws securityhub enable-security-hub \42 --enable-default-standards \43 --region us-east-14445# Enable specific standards46aws securityhub batch-enable-standards \47 --standards-subscription-requests \48 '{"StandardsArn":"arn:aws:securityhub:us-east-1::standards/aws-foundational-security-best-practices/v/1.0.0"}' \49 '{"StandardsArn":"arn:aws:securityhub:us-east-1::standards/cis-aws-foundations-benchmark/v/1.4.0"}'5051# Get findings summary52aws securityhub get-findings \53 --filters '{"SeverityLabel":[{"Value":"CRITICAL","Comparison":"EQUALS"}],"RecordState":[{"Value":"ACTIVE","Comparison":"EQUALS"}]}' \54 --max-items 1055```5657### Security Hub Standards58| Standard | Description |59|----------|------------|60| AWS Foundational Security Best Practices | AWS-recommended baseline controls |61| CIS AWS Foundations Benchmark 1.4 | CIS hardening requirements |62| PCI DSS v3.2.1 | Payment card industry controls |63| NIST SP 800-53 Rev 5 | Federal security controls |6465## Azure Defender for Cloud6667### Enable Defender CSPM68```bash69# Enable Defender for Cloud free tier70az security pricing create \71 --name CloudPosture \72 --tier standard7374# Check secure score75az security secure-score list \76 --query "[].{Name:displayName,Score:current,Max:max}" \77 --output table7879# Get security recommendations80az security assessment list \81 --query "[?status.code=='Unhealthy'].{Name:displayName,Severity:metadata.severity,Resource:resourceDetails.id}" \82 --output table8384# Get alerts85az security alert list \86 --query "[?status=='Active'].{Name:alertDisplayName,Severity:severity,Time:timeGeneratedUtc}" \87 --output table88```8990## Open-Source: Prowler9192### Installation and Execution93```bash94# Install Prowler95pip install prowler9697# Run full AWS scan98prowler aws --output-formats json-ocsf,csv,html99100# Run specific checks101prowler aws --checks s3_bucket_public_access iam_root_mfa_enabled ec2_sg_open_to_internet102103# Run against specific AWS profile and region104prowler aws --profile production --region us-east-1 --output-formats json-ocsf105106# Run CIS Benchmark compliance check107prowler aws --compliance cis_1.5_aws108109# Run PCI DSS compliance110prowler aws --compliance pci_3.2.1_aws111112# Scan Azure environment113prowler azure --subscription-ids "sub-id-here"114115# Scan GCP environment116prowler gcp --project-ids "project-id-here"117```118119### Prowler Check Categories120| Category | Examples |121|----------|---------|122| IAM | Root MFA, password policy, access key rotation |123| S3 | Public access, encryption, versioning |124| EC2 | Security groups, EBS encryption, metadata service |125| RDS | Public access, encryption, backup retention |126| CloudTrail | Enabled, encrypted, log validation |127| VPC | Flow logs, default SG restrictions |128| Lambda | Public access, runtime versions |129| EKS | Public endpoint, secrets encryption |130131## Open-Source: ScoutSuite132133```bash134# Install ScoutSuite135pip install scoutsuite136137# Run AWS assessment138scout aws --profile production139140# Run Azure assessment141scout azure --cli142143# Run GCP assessment144scout gcp --project-id my-project145146# Results available as interactive HTML report147# Open scout-report/report.html in browser148```149150## Multi-Cloud Aggregation151152```python153import json154import subprocess155from datetime import datetime, timezone156157def run_prowler_scan(provider, output_dir, compliance=None):158 """Run Prowler scan for a cloud provider."""159 cmd = ["prowler", provider, "--output-formats", "json-ocsf",160 "--output-directory", output_dir]161 if compliance:162 cmd.extend(["--compliance", compliance])163 result = subprocess.run(cmd, capture_output=True, text=True, timeout=3600)164 return result.returncode == 0165166def aggregate_findings(prowler_dirs):167 """Aggregate findings from multiple Prowler scans."""168 all_findings = []169 for scan_dir in prowler_dirs:170 json_files = list(Path(scan_dir).glob("*.json"))171 for jf in json_files:172 with open(jf, "r") as f:173 for line in f:174 try:175 finding = json.loads(line.strip())176 all_findings.append(finding)177 except json.JSONDecodeError:178 continue179 # Sort by severity180 severity_order = {"critical": 0, "high": 1, "medium": 2, "low": 3, "informational": 4}181 all_findings.sort(key=lambda f: severity_order.get(182 f.get("severity", "informational").lower(), 5183 ))184 return all_findings185186def generate_posture_report(findings, output_path):187 """Generate cloud security posture report."""188 report = {189 "generated_at": datetime.now(timezone.utc).isoformat(),190 "total_findings": len(findings),191 "by_severity": {},192 "by_provider": {},193 "by_service": {},194 }195 for f in findings:196 sev = f.get("severity", "unknown")197 provider = f.get("cloud_provider", "unknown")198 service = f.get("service_name", "unknown")199 report["by_severity"][sev] = report["by_severity"].get(sev, 0) + 1200 report["by_provider"][provider] = report["by_provider"].get(provider, 0) + 1201 report["by_service"][service] = report["by_service"].get(service, 0) + 1202203 with open(output_path, "w") as f:204 json.dump(report, f, indent=2)205 return report206```207208## References209210- [AWS Security Hub](https://aws.amazon.com/security-hub/)211- [Azure Defender for Cloud](https://learn.microsoft.com/en-us/azure/defender-for-cloud/)212- [Prowler](https://github.com/prowler-cloud/prowler)213- [ScoutSuite](https://github.com/nccgroup/ScoutSuite)214- [CIS Benchmarks](https://www.cisecurity.org/cis-benchmarks)