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.
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: MIT10metadata:11 source: https://skillmd.com/skills/njones17/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.1920## Prerequisites2122- AWS CLI configured with SecurityAudit IAM policy23- Azure CLI with Security Reader role24- Python 3.9+ with `boto3`, `azure-identity`, `azure-mgmt-security`25- Prowler (https://github.com/prowler-cloud/prowler)26- ScoutSuite (https://github.com/nccgroup/ScoutSuite)2728## AWS Security Hub2930### Enable Security Hub31```bash32# Enable AWS Security Hub with default standards33aws securityhub enable-security-hub \34 --enable-default-standards \35 --region us-east-13637# Enable specific standards38aws securityhub batch-enable-standards \39 --standards-subscription-requests \40 '{"StandardsArn":"arn:aws:securityhub:us-east-1::standards/aws-foundational-security-best-practices/v/1.0.0"}' \41 '{"StandardsArn":"arn:aws:securityhub:us-east-1::standards/cis-aws-foundations-benchmark/v/1.4.0"}'4243# Get findings summary44aws securityhub get-findings \45 --filters '{"SeverityLabel":[{"Value":"CRITICAL","Comparison":"EQUALS"}],"RecordState":[{"Value":"ACTIVE","Comparison":"EQUALS"}]}' \46 --max-items 1047```4849### Security Hub Standards50| Standard | Description |51|----------|------------|52| AWS Foundational Security Best Practices | AWS-recommended baseline controls |53| CIS AWS Foundations Benchmark 1.4 | CIS hardening requirements |54| PCI DSS v3.2.1 | Payment card industry controls |55| NIST SP 800-53 Rev 5 | Federal security controls |5657## Azure Defender for Cloud5859### Enable Defender CSPM60```bash61# Enable Defender for Cloud free tier62az security pricing create \63 --name CloudPosture \64 --tier standard6566# Check secure score67az security secure-score list \68 --query "[].{Name:displayName,Score:current,Max:max}" \69 --output table7071# Get security recommendations72az security assessment list \73 --query "[?status.code=='Unhealthy'].{Name:displayName,Severity:metadata.severity,Resource:resourceDetails.id}" \74 --output table7576# Get alerts77az security alert list \78 --query "[?status=='Active'].{Name:alertDisplayName,Severity:severity,Time:timeGeneratedUtc}" \79 --output table80```8182## Open-Source: Prowler8384### Installation and Execution85```bash86# Install Prowler87pip install prowler8889# Run full AWS scan90prowler aws --output-formats json-ocsf,csv,html9192# Run specific checks93prowler aws --checks s3_bucket_public_access iam_root_mfa_enabled ec2_sg_open_to_internet9495# Run against specific AWS profile and region96prowler aws --profile production --region us-east-1 --output-formats json-ocsf9798# Run CIS Benchmark compliance check99prowler aws --compliance cis_1.5_aws100101# Run PCI DSS compliance102prowler aws --compliance pci_3.2.1_aws103104# Scan Azure environment105prowler azure --subscription-ids "sub-id-here"106107# Scan GCP environment108prowler gcp --project-ids "project-id-here"109```110111### Prowler Check Categories112| Category | Examples |113|----------|---------|114| IAM | Root MFA, password policy, access key rotation |115| S3 | Public access, encryption, versioning |116| EC2 | Security groups, EBS encryption, metadata service |117| RDS | Public access, encryption, backup retention |118| CloudTrail | Enabled, encrypted, log validation |119| VPC | Flow logs, default SG restrictions |120| Lambda | Public access, runtime versions |121| EKS | Public endpoint, secrets encryption |122123## Open-Source: ScoutSuite124125```bash126# Install ScoutSuite127pip install scoutsuite128129# Run AWS assessment130scout aws --profile production131132# Run Azure assessment133scout azure --cli134135# Run GCP assessment136scout gcp --project-id my-project137138# Results available as interactive HTML report139# Open scout-report/report.html in browser140```141142## Multi-Cloud Aggregation143144```python145import json146import subprocess147from datetime import datetime, timezone148149def run_prowler_scan(provider, output_dir, compliance=None):150 """Run Prowler scan for a cloud provider."""151 cmd = ["prowler", provider, "--output-formats", "json-ocsf",152 "--output-directory", output_dir]153 if compliance:154 cmd.extend(["--compliance", compliance])155 result = subprocess.run(cmd, capture_output=True, text=True, timeout=3600)156 return result.returncode == 0157158def aggregate_findings(prowler_dirs):159 """Aggregate findings from multiple Prowler scans."""160 all_findings = []161 for scan_dir in prowler_dirs:162 json_files = list(Path(scan_dir).glob("*.json"))163 for jf in json_files:164 with open(jf, "r") as f:165 for line in f:166 try:167 finding = json.loads(line.strip())168 all_findings.append(finding)169 except json.JSONDecodeError:170 continue171 # Sort by severity172 severity_order = {"critical": 0, "high": 1, "medium": 2, "low": 3, "informational": 4}173 all_findings.sort(key=lambda f: severity_order.get(174 f.get("severity", "informational").lower(), 5175 ))176 return all_findings177178def generate_posture_report(findings, output_path):179 """Generate cloud security posture report."""180 report = {181 "generated_at": datetime.now(timezone.utc).isoformat(),182 "total_findings": len(findings),183 "by_severity": {},184 "by_provider": {},185 "by_service": {},186 }187 for f in findings:188 sev = f.get("severity", "unknown")189 provider = f.get("cloud_provider", "unknown")190 service = f.get("service_name", "unknown")191 report["by_severity"][sev] = report["by_severity"].get(sev, 0) + 1192 report["by_provider"][provider] = report["by_provider"].get(provider, 0) + 1193 report["by_service"][service] = report["by_service"].get(service, 0) + 1194195 with open(output_path, "w") as f:196 json.dump(report, f, indent=2)197 return report198```199200## References201202- [AWS Security Hub](https://aws.amazon.com/security-hub/)203- [Azure Defender for Cloud](https://learn.microsoft.com/en-us/azure/defender-for-cloud/)204- [Prowler](https://github.com/prowler-cloud/prowler)205- [ScoutSuite](https://github.com/nccgroup/ScoutSuite)206- [CIS Benchmarks](https://www.cisecurity.org/cis-benchmarks)