Skip to main content

CloudSentrix ๐Ÿ”

GCP IAM Privilege-Escalation Attack-Path Analyzer

CloudSentrix is a free, open-source command-line tool that scans Google Cloud Platform IAM policy exports for privilege-escalation risks, generates interactive attack-path graphs, scores your security posture, and produces client-ready PDF reports โ€” all without any paid APIs.

CI Python License Tests


What It Does

  • Detects 5 GCP IAM privilege-escalation patterns (mapped to MITRE ATT&CK Cloud Matrix)
  • Scores your project's security posture from 0โ€“100
  • Calculates blast radius โ€” if one account is compromised, how much can an attacker reach?
  • Generates remediation โ€” exact gcloud CLI commands to fix each finding
  • Exports results as JSON, CSV, SARIF, Interactive HTML Dashboard, or client-ready PDF
  • Live scanning โ€” fetch and scan a live GCP project directly (no file needed)
  • Watches a folder and auto-rescans whenever an IAM file changes
  • AI summaries โ€” plain-language executive summaries via Google Gemini

Requirements

  • Python 3.10 or higher
  • pip

Installation

Windows

git clone https://github.com/Talha-Imran-cloud/cloudsentrix.git
cd cloudsentrix
python -m venv venv
venv\Scripts\activate
pip install -e .

Linux / macOS (Kali, Ubuntu, Debian)

git clone https://github.com/Talha-Imran-cloud/cloudsentrix.git
cd cloudsentrix
python3 -m venv venv
source venv/bin/activate
pip install -e .

Verify installation

cloudsentrix --version

Getting Your GCP IAM Policy File

gcloud projects get-iam-policy YOUR_PROJECT_ID --format=json > my_project_iam.json

Two sample files are included for testing:

  • sample_data/sample_gcp_iam.json โ€” basic 5-principal example
  • sample_data/demo_enterprise_iam.json โ€” realistic enterprise scenario

Commands

scan โ€” Full pipeline scan

cloudsentrix scan --file sample_data/sample_gcp_iam.json
cloudsentrix scan --file my_project.json --severity high
cloudsentrix scan --file my_project.json --top 10

live-scan โ€” Scan a live GCP project directly โšก NEW

# Requires: gcloud CLI authenticated
gcloud auth application-default login

# Fetch and scan live IAM policy
cloudsentrix live-scan --project my-gcp-project-id

# Scan and save the fetched policy
cloudsentrix live-scan --project my-gcp-project-id --save fetched_policy.json

# Filter by severity
cloudsentrix live-scan --project my-gcp-project-id --severity critical

blast-radius โ€” Blast radius for one principal

cloudsentrix blast-radius --file my_project.json --principal admin@company.com

principal-path โ€” Escalation path between two principals

cloudsentrix principal-path --file my_project.json \
  --source intern@company.com \
  --target app-backend@my-project.iam.gserviceaccount.com

mitre-map โ€” Map findings to MITRE ATT&CK Cloud Matrix

cloudsentrix mitre-map --file my_project.json

remediate โ€” Generate exact gcloud fix commands

cloudsentrix remediate --file my_project.json
cloudsentrix remediate --file my_project.json --project my-real-project-id
cloudsentrix remediate --file my_project.json --severity critical

score โ€” Security score only (for CI/CD badges)

cloudsentrix score --file my_project.json
cloudsentrix score --file my_project.json --json
cloudsentrix score --file my_project.json --min-score 70

validate โ€” Check file format before scanning

cloudsentrix validate --file my_project.json

compare โ€” Compare two IAM exports (detect new risks)

cloudsentrix compare --old january.json --new february.json

export โ€” Export results to JSON, CSV, HTML, or SARIF

# JSON export
cloudsentrix export --file my_project.json --output report.json

# CSV export
cloudsentrix export --file my_project.json --output report.csv

# Interactive HTML Dashboard (open in browser)
cloudsentrix export --file my_project.json --output dashboard.html

# SARIF export (GitHub Code Scanning compatible) โšก NEW
cloudsentrix export --file my_project.json --output results.sarif

Opening the HTML Dashboard:

Windows:

start dashboard.html

Linux / macOS:

xdg-open dashboard.html

The HTML dashboard includes:

  • Security score card
  • Finding counts by severity
  • Interactive attack graph (drag nodes, scroll to zoom, hover for details)
  • Full findings table with MITRE mapping
  • Blast radius table

report โ€” Generate a client-ready PDF report

# Without AI summary
cloudsentrix report --file my_project.json --output my_report.pdf --no-ai

# With Gemini AI summary (set API key first โ€” see below)
cloudsentrix report --file my_project.json --output my_report.pdf

watch โ€” Auto-rescan when file changes

# Watch a single file
cloudsentrix watch --path my_project.json

# Watch a folder (rescans any .json file that changes)
cloudsentrix watch --path /path/to/iam/exports/

# Custom poll interval (seconds)
cloudsentrix watch --path my_project.json --interval 5

Press Ctrl+C to stop watching.

rules โ€” List all detection rules

cloudsentrix rules

list-principals โ€” List all principals and their roles

cloudsentrix list-principals --file my_project.json

SARIF Export โ€” GitHub Code Scanning โšก NEW

SARIF (Static Analysis Results Interchange Format) output is compatible with:

  • GitHub Code Scanning โ€” upload directly to your repo's Security tab
  • VS Code SARIF Viewer extension
  • Azure DevOps security dashboards
  • Any SARIF 2.1.0-compatible tool
cloudsentrix export --file my_project.json --output results.sarif

Upload to GitHub:

gh api repos/OWNER/REPO/code-scanning/sarifs \
  -F sarif=@results.sarif \
  -F ref=refs/heads/main \
  -F commit_sha=$(git rev-parse HEAD)

Gemini AI Summary (Optional)

The report command can generate a plain-language AI summary using Google Gemini.

Step 1 โ€” Get a free API key from Google AI Studio

Step 2 โ€” Set the environment variable:

Windows:

$env:GEMINI_API_KEY = "your_api_key_here"

Linux / macOS:

export GEMINI_API_KEY="your_api_key_here"

Step 3 โ€” Run:

cloudsentrix report --file my_project.json --output report.pdf

If no API key is set, a built-in template summary is used automatically.


Exit Codes

Code Meaning
0 Success, no CRITICAL findings
1 CRITICAL findings detected (use this to fail CI pipelines)
2 Command could not complete (bad file, wrong format, etc.)

Detection Rules

Rule Title Severity MITRE
GCP-001 Publicly Accessible Role Binding CRITICAL T1078.004
GCP-002 Service Account Token Creator CRITICAL T1098.001
GCP-003 Service Account Key Admin CRITICAL T1098.001
GCP-004 IAM Policy Administrator CRITICAL T1098.003
GCP-005 Service Account Impersonation via Resource Attach HIGH T1548.005

Running Tests

pip install -e ".[dev]"
pytest tests/ -v

Expected output: 144 passed


Project Structure

cloudsentrix/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ cli.py              # CLI entry point (15 commands)
โ”‚   โ”œโ”€โ”€ parser.py           # GCP IAM JSON parser
โ”‚   โ”œโ”€โ”€ graph.py            # IAM permission graph engine
โ”‚   โ”œโ”€โ”€ detection.py        # Privilege-escalation detection rules
โ”‚   โ”œโ”€โ”€ risk_score.py       # 0-100 security scoring engine
โ”‚   โ”œโ”€โ”€ blast_radius.py     # Attack-path blast radius calculator
โ”‚   โ”œโ”€โ”€ watch_handler.py    # File system watcher
โ”‚   โ”œโ”€โ”€ live_scanner.py     # Live GCP project scanner
โ”‚   โ”œโ”€โ”€ pdf_report.py       # PDF report generator
โ”‚   โ””โ”€โ”€ ai_summary.py       # Gemini AI summary integration
โ”œโ”€โ”€ tests/                  # 144 pytest tests
โ”œโ”€โ”€ sample_data/
โ”‚   โ”œโ”€โ”€ sample_gcp_iam.json         # Basic test file
โ”‚   โ””โ”€โ”€ demo_enterprise_iam.json    # Realistic enterprise demo
โ”œโ”€โ”€ .github/workflows/ci.yml        # GitHub Actions CI
โ”œโ”€โ”€ pyproject.toml                  # Packaging configuration
โ””โ”€โ”€ README.md

Roadmap ๐Ÿ—บ๏ธ

Coming Soon

Feature Description Status
AWS Support Scan AWS IAM policies โ€” detect privilege escalation via iam:PassRole, sts:AssumeRole, admin policies ๐Ÿ”„ Planned
Azure Support Scan Azure RBAC โ€” detect Owner/Contributor abuse, service principal risks ๐Ÿ”„ Planned
Multi-Cloud Dashboard Single HTML dashboard comparing GCP, AWS, Azure risk side by side ๐Ÿ”„ Planned
Slack / Teams Alerts Send findings to Slack or Microsoft Teams webhook automatically ๐Ÿ”„ Planned
PDF Multi-Project One PDF report covering multiple GCP projects at once ๐Ÿ”„ Planned

AWS Support (Preview)

When AWS support ships, usage will look like:

# Export AWS IAM data
aws iam get-account-authorization-details --output json > aws_iam.json

# Scan AWS
cloudsentrix scan --file aws_iam.json --cloud aws

Azure Support (Preview)

# Export Azure RBAC
az role assignment list --all --output json > azure_rbac.json

# Scan Azure
cloudsentrix scan --file azure_rbac.json --cloud azure

License

MIT License โ€” free to use, modify, and distribute.


Author

Talha Imran โ€” SOC Analyst | Cloud Security | Pentesting

GitHub LinkedIn

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudsentrix-1.0.0.tar.gz (53.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloudsentrix-1.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file cloudsentrix-1.0.0.tar.gz.

File metadata

  • Download URL: cloudsentrix-1.0.0.tar.gz
  • Upload date:
  • Size: 53.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cloudsentrix-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1ff789ebff851ebdd00e9640532bb0306a28ada1d249e17d86f270f93730c46a
MD5 87357c27593e8eb282618862ef87bc05
BLAKE2b-256 5eca2174ca1d78d1600a922cfb58c35491b276d08931a6ed75e0210efd8c072e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cloudsentrix-1.0.0.tar.gz:

Publisher: publish.yml on Talha-Imran-cloud/cloudsentrix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cloudsentrix-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: cloudsentrix-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cloudsentrix-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e49767b4d21fb65d0de0879b71bd975abc16f6137ca2014c31111111a67524f
MD5 1f01960b53d2a5cfbff7921bddfd0a85
BLAKE2b-256 3ee94717995361905d7759177cc314e1fb9886b4e4cc83b5ef96bdebafacfbdb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cloudsentrix-1.0.0-py3-none-any.whl:

Publisher: publish.yml on Talha-Imran-cloud/cloudsentrix

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page