cloudthreat-agent 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cloudthreat_agent-1.0.0/.env.example +7 -0
- cloudthreat_agent-1.0.0/.github/workflows/ci.yml +39 -0
- cloudthreat_agent-1.0.0/.github/workflows/release.yml +56 -0
- cloudthreat_agent-1.0.0/.gitignore +62 -0
- cloudthreat_agent-1.0.0/.gitmodules +40 -0
- cloudthreat_agent-1.0.0/.pre-commit-config.yaml +31 -0
- cloudthreat_agent-1.0.0/CHANGELOG.md +17 -0
- cloudthreat_agent-1.0.0/LICENSE +202 -0
- cloudthreat_agent-1.0.0/NOTICE +16 -0
- cloudthreat_agent-1.0.0/PKG-INFO +152 -0
- cloudthreat_agent-1.0.0/README.md +122 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/batch_pool/main.tf +56 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/container_app/main.tf +45 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/count_var_role/main.tf +25 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/data_factory/main.tf +36 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/for_each_role/main.tf +21 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/logic_app/main.tf +36 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/remote_module/main.tf +17 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/runbook_without_r23/main.tf +49 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/trap_container_reader/main.tf +44 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/trap_eventhub_keys/main.tf +37 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/trap_logic_operator/main.tf +35 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/trap_other_rg/main.tf +54 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/trap_reader/main.tf +38 -0
- cloudthreat_agent-1.0.0/benchmarks/gaps/trap_servicebus_keys/main.tf +38 -0
- cloudthreat_agent-1.0.0/ground_truth/gaps.yaml +150 -0
- cloudthreat_agent-1.0.0/ground_truth/unseen.yaml +114 -0
- cloudthreat_agent-1.0.0/ground_truth/xmgoat.yaml +80 -0
- cloudthreat_agent-1.0.0/pyproject.toml +72 -0
- cloudthreat_agent-1.0.0/scripts/adx_s10.py +169 -0
- cloudthreat_agent-1.0.0/scripts/benchmark.py +122 -0
- cloudthreat_agent-1.0.0/scripts/measure_gaps.py +105 -0
- cloudthreat_agent-1.0.0/scripts/measure_sigma.py +69 -0
- cloudthreat_agent-1.0.0/scripts/obfuscate_lab.py +59 -0
- cloudthreat_agent-1.0.0/scripts/rule_candidates_docs.py +139 -0
- cloudthreat_agent-1.0.0/scripts/rule_shortlist.py +82 -0
- cloudthreat_agent-1.0.0/scripts/update_builtin_roles.py +75 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/__init__.py +5 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/agent/__init__.py +0 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/agent/candidates.py +89 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/agent/docsearch.py +65 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/agent/loop.py +490 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/agent/tools.py +383 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/cli.py +186 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/data/azure_builtin_roles.json +10978 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/detections/__init__.py +0 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/detections/catalog.py +109 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/detections/draft.py +138 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/detections/sigma.py +167 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/gaps.py +156 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/graph/__init__.py +0 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/graph/build.py +399 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/models.py +105 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/parsers/__init__.py +0 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/parsers/terraform_hcl.py +463 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/parsers/terraform_plan.py +146 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/paths.py +108 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/remediate.py +155 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/report/__init__.py +0 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/report/markdown.py +162 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/report/sarif.py +122 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/rules.py +411 -0
- cloudthreat_agent-1.0.0/src/cloudthreat/scanners.py +75 -0
- cloudthreat_agent-1.0.0/tests/fixtures/basic/main.tf +118 -0
- cloudthreat_agent-1.0.0/tests/fixtures/plan_hybrid/main.tf +25 -0
- cloudthreat_agent-1.0.0/tests/fixtures/plan_hybrid/plan.json +89 -0
- cloudthreat_agent-1.0.0/tests/test_adx_s10.py +65 -0
- cloudthreat_agent-1.0.0/tests/test_benchmark.py +19 -0
- cloudthreat_agent-1.0.0/tests/test_cli.py +81 -0
- cloudthreat_agent-1.0.0/tests/test_detections.py +99 -0
- cloudthreat_agent-1.0.0/tests/test_draft.py +48 -0
- cloudthreat_agent-1.0.0/tests/test_gaps.py +137 -0
- cloudthreat_agent-1.0.0/tests/test_graph.py +243 -0
- cloudthreat_agent-1.0.0/tests/test_loop.py +337 -0
- cloudthreat_agent-1.0.0/tests/test_obfuscate_lab.py +54 -0
- cloudthreat_agent-1.0.0/tests/test_paths.py +120 -0
- cloudthreat_agent-1.0.0/tests/test_plan.py +66 -0
- cloudthreat_agent-1.0.0/tests/test_real_projects.py +28 -0
- cloudthreat_agent-1.0.0/tests/test_remediate.py +91 -0
- cloudthreat_agent-1.0.0/tests/test_report.py +77 -0
- cloudthreat_agent-1.0.0/tests/test_rule_candidates_docs.py +42 -0
- cloudthreat_agent-1.0.0/tests/test_rule_shortlist.py +49 -0
- cloudthreat_agent-1.0.0/tests/test_rules.py +222 -0
- cloudthreat_agent-1.0.0/tests/test_scanners.py +115 -0
- cloudthreat_agent-1.0.0/tests/test_terraform_hcl.py +371 -0
- cloudthreat_agent-1.0.0/tests/test_tools.py +206 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
secrets:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
- name: Scan for secrets (gitleaks)
|
|
19
|
+
run: |
|
|
20
|
+
docker run --rm -v "$PWD:/repo" ghcr.io/gitleaks/gitleaks:v8.30.0 \
|
|
21
|
+
git /repo --redact --verbose
|
|
22
|
+
|
|
23
|
+
quality:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v7
|
|
27
|
+
- uses: actions/setup-python@v7
|
|
28
|
+
with:
|
|
29
|
+
python-version: "3.12"
|
|
30
|
+
- name: Install
|
|
31
|
+
run: pip install -e ".[dev]"
|
|
32
|
+
- name: Lint (ruff)
|
|
33
|
+
run: |
|
|
34
|
+
ruff check .
|
|
35
|
+
ruff format --check .
|
|
36
|
+
- name: Types (mypy)
|
|
37
|
+
run: mypy
|
|
38
|
+
- name: Tests (pytest)
|
|
39
|
+
run: pytest
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v7
|
|
15
|
+
- uses: actions/setup-python@v7
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- name: Build
|
|
19
|
+
run: |
|
|
20
|
+
pip install build twine
|
|
21
|
+
python -m build
|
|
22
|
+
twine check dist/*
|
|
23
|
+
- name: Tag matches version
|
|
24
|
+
run: test "v$(python -c 'import tomllib;print(tomllib.load(open("pyproject.toml","rb"))["project"]["version"])')" = "$GITHUB_REF_NAME"
|
|
25
|
+
- uses: actions/upload-artifact@v4
|
|
26
|
+
with:
|
|
27
|
+
name: dist
|
|
28
|
+
path: dist/
|
|
29
|
+
|
|
30
|
+
github-release:
|
|
31
|
+
needs: build
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
permissions:
|
|
34
|
+
contents: write
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/download-artifact@v4
|
|
37
|
+
with:
|
|
38
|
+
name: dist
|
|
39
|
+
path: dist/
|
|
40
|
+
- name: Create GitHub release
|
|
41
|
+
env:
|
|
42
|
+
GH_TOKEN: ${{ github.token }}
|
|
43
|
+
run: gh release create "$GITHUB_REF_NAME" dist/* --repo "$GITHUB_REPOSITORY" --title "$GITHUB_REF_NAME" --notes "See CHANGELOG.md"
|
|
44
|
+
|
|
45
|
+
pypi:
|
|
46
|
+
needs: build
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
environment: pypi
|
|
49
|
+
permissions:
|
|
50
|
+
id-token: write # PyPI trusted publishing: no token stored in the repo
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/download-artifact@v4
|
|
53
|
+
with:
|
|
54
|
+
name: dist
|
|
55
|
+
path: dist/
|
|
56
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# --- Secrets and credentials: never commit ---
|
|
2
|
+
.env
|
|
3
|
+
.env.*
|
|
4
|
+
!.env.example
|
|
5
|
+
*.pem
|
|
6
|
+
*.key
|
|
7
|
+
*.pfx
|
|
8
|
+
*.p12
|
|
9
|
+
id_rsa*
|
|
10
|
+
id_ed25519*
|
|
11
|
+
*credentials*
|
|
12
|
+
*.secret
|
|
13
|
+
|
|
14
|
+
# --- Terraform state, variables and plans (may contain secrets) ---
|
|
15
|
+
.terraform/
|
|
16
|
+
.terraform.lock.hcl
|
|
17
|
+
*.tfstate
|
|
18
|
+
*.tfstate.*
|
|
19
|
+
*.tfvars
|
|
20
|
+
*.tfvars.json
|
|
21
|
+
*.tfplan
|
|
22
|
+
plan.out
|
|
23
|
+
plan.json
|
|
24
|
+
# synthetic test fixture (mocked providers, placeholder IDs only)
|
|
25
|
+
!tests/fixtures/plan_hybrid/plan.json
|
|
26
|
+
crash.log
|
|
27
|
+
crash.*.log
|
|
28
|
+
override.tf
|
|
29
|
+
override.tf.json
|
|
30
|
+
*_override.tf
|
|
31
|
+
*_override.tf.json
|
|
32
|
+
|
|
33
|
+
# --- Outputs of live runs (may contain tenant / subscription IDs) ---
|
|
34
|
+
outputs/
|
|
35
|
+
reports/
|
|
36
|
+
*.sarif
|
|
37
|
+
live-runs/
|
|
38
|
+
|
|
39
|
+
# --- Private benchmark scenarios (kept out of the public repo on purpose) ---
|
|
40
|
+
benchmarks/scenarios_private/
|
|
41
|
+
|
|
42
|
+
# --- Python ---
|
|
43
|
+
__pycache__/
|
|
44
|
+
*.py[cod]
|
|
45
|
+
.venv/
|
|
46
|
+
venv/
|
|
47
|
+
build/
|
|
48
|
+
dist/
|
|
49
|
+
*.egg-info/
|
|
50
|
+
.pytest_cache/
|
|
51
|
+
.mypy_cache/
|
|
52
|
+
.ruff_cache/
|
|
53
|
+
.coverage
|
|
54
|
+
.coverage.*
|
|
55
|
+
htmlcov/
|
|
56
|
+
coverage.xml
|
|
57
|
+
|
|
58
|
+
# --- Editors / OS ---
|
|
59
|
+
.vscode/
|
|
60
|
+
.idea/
|
|
61
|
+
.DS_Store
|
|
62
|
+
Thumbs.db
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[submodule "labs/terragoat"]
|
|
2
|
+
path = labs/terragoat
|
|
3
|
+
url = https://github.com/bridgecrewio/terragoat.git
|
|
4
|
+
shallow = true
|
|
5
|
+
[submodule "labs/azuregoat"]
|
|
6
|
+
path = labs/azuregoat
|
|
7
|
+
url = https://github.com/ine-labs/AzureGoat.git
|
|
8
|
+
shallow = true
|
|
9
|
+
[submodule "labs/xmgoat"]
|
|
10
|
+
path = labs/xmgoat
|
|
11
|
+
url = https://github.com/XMCyber/XMGoat.git
|
|
12
|
+
shallow = true
|
|
13
|
+
[submodule "labs/physical-ai-toolchain"]
|
|
14
|
+
path = labs/physical-ai-toolchain
|
|
15
|
+
url = https://github.com/microsoft/physical-ai-toolchain
|
|
16
|
+
shallow = true
|
|
17
|
+
[submodule "labs/unseen/functions-quickstart-dotnet-azd-tf"]
|
|
18
|
+
path = labs/unseen/functions-quickstart-dotnet-azd-tf
|
|
19
|
+
url = https://github.com/Azure-Samples/functions-quickstart-dotnet-azd-tf.git
|
|
20
|
+
shallow = true
|
|
21
|
+
[submodule "labs/unseen/ai-gateway-foundry-terraform"]
|
|
22
|
+
path = labs/unseen/ai-gateway-foundry-terraform
|
|
23
|
+
url = https://github.com/Azure-Samples/ai-gateway-foundry-terraform.git
|
|
24
|
+
shallow = true
|
|
25
|
+
[submodule "labs/unseen/aks-openai-terraform"]
|
|
26
|
+
path = labs/unseen/aks-openai-terraform
|
|
27
|
+
url = https://github.com/Azure-Samples/aks-openai-terraform.git
|
|
28
|
+
shallow = true
|
|
29
|
+
[submodule "labs/unseen/Microhack-Ask-Analyze-Act"]
|
|
30
|
+
path = labs/unseen/Microhack-Ask-Analyze-Act
|
|
31
|
+
url = https://github.com/Azure-Samples/Microhack-Ask-Analyze-Act.git
|
|
32
|
+
shallow = true
|
|
33
|
+
[submodule "labs/unseen/APIM-Unified-AI-Gateway-Sample"]
|
|
34
|
+
path = labs/unseen/APIM-Unified-AI-Gateway-Sample
|
|
35
|
+
url = https://github.com/Azure-Samples/APIM-Unified-AI-Gateway-Sample.git
|
|
36
|
+
shallow = true
|
|
37
|
+
[submodule "labs/unseen/Copilot-Studio-with-Azure-AI-Search"]
|
|
38
|
+
path = labs/unseen/Copilot-Studio-with-Azure-AI-Search
|
|
39
|
+
url = https://github.com/Azure-Samples/Copilot-Studio-with-Azure-AI-Search.git
|
|
40
|
+
shallow = true
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v6.0.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: check-added-large-files
|
|
6
|
+
- id: check-merge-conflict
|
|
7
|
+
- id: detect-private-key
|
|
8
|
+
- id: end-of-file-fixer
|
|
9
|
+
- id: trailing-whitespace
|
|
10
|
+
- id: check-yaml
|
|
11
|
+
- id: check-toml
|
|
12
|
+
|
|
13
|
+
- repo: https://github.com/gitleaks/gitleaks
|
|
14
|
+
rev: v8.30.0
|
|
15
|
+
hooks:
|
|
16
|
+
- id: gitleaks
|
|
17
|
+
|
|
18
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
19
|
+
rev: v0.17.6
|
|
20
|
+
hooks:
|
|
21
|
+
- id: ruff-check
|
|
22
|
+
args: [--fix]
|
|
23
|
+
- id: ruff-format
|
|
24
|
+
|
|
25
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
26
|
+
rev: v2.4.1
|
|
27
|
+
hooks:
|
|
28
|
+
- id: mypy
|
|
29
|
+
args: [--strict]
|
|
30
|
+
additional_dependencies: ["pydantic>=2.7", "python-hcl2>=8", "networkx>=3.3", "types-networkx", "ollama>=0.4", "types-PyYAML", "pysigma>=0.11,<0.12", "pysigma-backend-kusto>=0.4,<0.5"]
|
|
31
|
+
files: ^src/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 - 2026-12-01
|
|
4
|
+
|
|
5
|
+
First release.
|
|
6
|
+
|
|
7
|
+
- Azure Terraform (`azurerm`, `azuread`) parsed into an identity-and-resource graph; local
|
|
8
|
+
modules followed; optional Terraform plan (`scan --plan`) for instances and remote modules.
|
|
9
|
+
- 20 sourced escalation rules (R10-R29): Azure RBAC, Entra roles, Graph permissions, owners,
|
|
10
|
+
group membership, managed identities and the compute that runs as them.
|
|
11
|
+
- Attack chains to crown jewels, with STRIDE, MITRE ATT&CK and a Terraform fix per chain.
|
|
12
|
+
- A Sigma rule per escalation rule, converted to KQL, validated in Azure Data Explorer
|
|
13
|
+
against documented log events.
|
|
14
|
+
- Optional local LLM judge (`scan --judge`, Ollama): unverified hypotheses, never in SARIF.
|
|
15
|
+
- Reports: JSON, Markdown, SARIF. Checkov and Trivy findings attached when installed.
|
|
16
|
+
- Public benchmark (`scripts/benchmark.py`): XMGoat, an obfuscated copy, six unseen
|
|
17
|
+
Azure-Samples projects with ground truth written before the first run, a gap benchmark.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
cloudthreat-agent
|
|
2
|
+
Copyright 2026 warzazate
|
|
3
|
+
|
|
4
|
+
This product includes third-party data:
|
|
5
|
+
|
|
6
|
+
Azure built-in role definitions
|
|
7
|
+
File: src/cloudthreat/data/azure_builtin_roles.json
|
|
8
|
+
Source: Microsoft Azure documentation, "Azure built-in roles"
|
|
9
|
+
https://github.com/MicrosoftDocs/azure-docs
|
|
10
|
+
(articles/role-based-access-control/built-in-roles/, commit recorded in the file)
|
|
11
|
+
Author: Microsoft Corporation
|
|
12
|
+
License: Creative Commons Attribution 4.0 International (CC BY 4.0)
|
|
13
|
+
https://creativecommons.org/licenses/by/4.0/
|
|
14
|
+
Changes: role names and permission lists (actions, notActions, dataActions,
|
|
15
|
+
notDataActions) extracted from the JSON blocks of the pages and
|
|
16
|
+
reformatted by scripts/update_builtin_roles.py; descriptions omitted.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: cloudthreat-agent
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Verified attack paths and validated detections from Azure Terraform, before deployment.
|
|
5
|
+
Author: warzazate
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: NOTICE
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Topic :: Security
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Requires-Dist: networkx>=3.3
|
|
14
|
+
Requires-Dist: ollama>=0.4
|
|
15
|
+
Requires-Dist: pydantic>=2.7
|
|
16
|
+
Requires-Dist: pyparsing<3.3.3
|
|
17
|
+
Requires-Dist: pysigma-backend-kusto<0.5,>=0.4
|
|
18
|
+
Requires-Dist: pysigma<0.12,>=0.11
|
|
19
|
+
Requires-Dist: python-hcl2>=8
|
|
20
|
+
Requires-Dist: pyyaml>=6
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
23
|
+
Requires-Dist: pre-commit>=3.7; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
27
|
+
Requires-Dist: types-networkx; extra == 'dev'
|
|
28
|
+
Requires-Dist: types-pyyaml; extra == 'dev'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# cloudthreat-agent
|
|
32
|
+
|
|
33
|
+
**Verified attack paths and validated detections from Azure Terraform, before deployment.**
|
|
34
|
+
|
|
35
|
+
`cloudthreat-agent` reads Azure Terraform, builds a deterministic identity-and-resource graph, and finds the attack paths an adversary could chain from misconfigurations. A local LLM agent explores the graph through tools, and every path it proposes is re-verified by deterministic code before it is reported. Each verified path comes with a STRIDE threat model, a Terraform fix, and a Sigma detection rule converted to KQL.
|
|
36
|
+
|
|
37
|
+
> **Status: v1.0 (beta).** Deterministic paths, Sigma/KQL detections and a public benchmark. Read its limits below before trusting a result.
|
|
38
|
+
|
|
39
|
+
## Why
|
|
40
|
+
|
|
41
|
+
IaC scanners such as Checkov and Trivy flag misconfigurations one resource at a time. They do not show how an attacker would chain them, or how to detect that chain once deployed. `cloudthreat-agent` aims to close that gap, and to publish an honest benchmark of where it succeeds and where it fails.
|
|
42
|
+
|
|
43
|
+
## Design principles
|
|
44
|
+
|
|
45
|
+
- **The LLM never reads raw Terraform.** It queries a graph built deterministically.
|
|
46
|
+
- **No unverified path is reported.** A path is kept only if every edge exists in the graph.
|
|
47
|
+
- **Runs fully local.** Default LLM backend is [Ollama](https://ollama.com); an `--offline` mode uses no LLM at all.
|
|
48
|
+
- **Honest benchmark.** Results against public vulnerable-by-design labs, including variance and failures.
|
|
49
|
+
|
|
50
|
+
## Roadmap
|
|
51
|
+
|
|
52
|
+
| Version | Milestone |
|
|
53
|
+
|---|---|
|
|
54
|
+
| v0.1 | Parse Azure Terraform into a graph, attach Checkov / Trivy findings |
|
|
55
|
+
| v0.2 | Deterministic privilege-escalation paths, tagged with MITRE ATT&CK |
|
|
56
|
+
| v0.3 | LLM agent with hypothesis-then-verification loop; Markdown, SARIF, JSON reports |
|
|
57
|
+
| v0.4 | Sigma rules converted to KQL, validated in Azure Data Explorer against documented log events (no live Azure subscription, so not replayed attacks) |
|
|
58
|
+
| v1.0 | Public benchmark on unseen projects, PyPI release |
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install cloudthreat-agent # Python 3.12+
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cloudthreat scan path/to/terraform > scan.json # graph, attack paths, fixes, findings
|
|
70
|
+
cloudthreat report scan.json --format md # or sarif (--source path/to/terraform)
|
|
71
|
+
cloudthreat sigma --kql # Sigma rule + KQL per escalation rule
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`scan --plan plan.json` completes the static parse with a Terraform plan you provide: `terraform show -json` from your pipeline, or the output of `terraform test -json -verbose` with mocked providers (no Azure credential). The plan gives one resource per `count` / `for_each` instance, role assignment values Terraform resolved, and the resources of remote modules; references between resources still come from the code.
|
|
75
|
+
|
|
76
|
+
`scan --judge --perms-docs DIR` (off by default) lets a local LLM judge identity takeovers the rules miss, among candidates the code enumerates, with a Sigma rule per hit. Its output is an unverified hypothesis, never written to SARIF.
|
|
77
|
+
|
|
78
|
+
## Benchmark
|
|
79
|
+
|
|
80
|
+
Reproduce it (Python 3.12+, deterministic, no LLM, about one minute from a fresh clone):
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/warzazate/cloudthreat-agent && cd cloudthreat-agent
|
|
84
|
+
git submodule update --init --depth 1 labs/xmgoat labs/unseen/*
|
|
85
|
+
python3.12 -m venv .venv && .venv/bin/pip install -e .
|
|
86
|
+
.venv/bin/python scripts/benchmark.py
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Results at commit time:
|
|
90
|
+
|
|
91
|
+
| Measure | Count | Rate |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| XMGoat, expected chains found | 6/6 | 100 % |
|
|
94
|
+
| XMGoat, other (entry, jewel) pairs found, not judged | 4 | |
|
|
95
|
+
| XMGoat obfuscated, expected chains found | 6/6 | 100 % |
|
|
96
|
+
| Unseen projects, expected pairs found (recall) | 7/12 | 58 % |
|
|
97
|
+
| Unseen projects, found pairs expected (precision) | 7/7 | 100 % |
|
|
98
|
+
| Gap benchmark, paths found by the rules | 3/8 | 38 % |
|
|
99
|
+
| Gap benchmark, false hops | 0 | |
|
|
100
|
+
| Hops of found chains with a Sigma / KQL rule | 42/42 | 100 % |
|
|
101
|
+
|
|
102
|
+
Read these numbers with their limits:
|
|
103
|
+
|
|
104
|
+
- **XMGoat is not a blind test.** Its ground truth was written during development and the
|
|
105
|
+
rules were built against it. The obfuscated copy (neutral resource names) only shows that
|
|
106
|
+
the rules do not rely on names.
|
|
107
|
+
- **Unseen projects: the honest scores are the first runs.** Six public Azure-Samples
|
|
108
|
+
projects in two batches, ground truth committed before the tool ever ran on them
|
|
109
|
+
(`ground_truth/unseen.yaml`). Batch 1 (3 small projects): 1/2 found, 1 false pair. Batch 2
|
|
110
|
+
(3 larger projects): 3/10 found, 1 false pair. Each run exposed bugs, fixed right after;
|
|
111
|
+
the table shows the score after the fixes, which is no longer a blind measure.
|
|
112
|
+
- **What the unseen projects still miss.** 2 pairs need a storage account inside a remote
|
|
113
|
+
registry module (use `--plan`). 3 pairs start from a principal that the tool shows only in
|
|
114
|
+
the middle of a longer chain (a group reached from its members, a service principal from
|
|
115
|
+
its owner): entries are the principals nothing else reaches.
|
|
116
|
+
- **LLM judge on batch 2 (`scan --judge`, cloudthreat-llm, qwen3 4B):** 1 candidate in the
|
|
117
|
+
3 projects (Search Service Contributor on a search service that runs as its own managed
|
|
118
|
+
identity), 0 kept. The takeover is real: a data source and indexer can authenticate with
|
|
119
|
+
the service identity. A false negative of the small model; the regex reference kept it,
|
|
120
|
+
for the wrong operation (`debugSessions/execute`).
|
|
121
|
+
- **XMGoat "other" pairs** include the deployer's own Key Vault access policies: true, but
|
|
122
|
+
expected, since the deployer created the vault.
|
|
123
|
+
- **The gap benchmark is built to fail.** Its cases are identity takeovers no rule covers;
|
|
124
|
+
38 % is the share the rules still reach, the rest is what an optional LLM judge
|
|
125
|
+
(`scan --judge`) is meant to find. No false hop.
|
|
126
|
+
- **Detection: 100 % by construction.** Every escalation rule has a Sigma template; the KQL is
|
|
127
|
+
validated on documented events only (see Limitations).
|
|
128
|
+
|
|
129
|
+
## Development
|
|
130
|
+
|
|
131
|
+
Requires Python 3.12+.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
python -m venv .venv && source .venv/bin/activate
|
|
135
|
+
pip install -e ".[dev]"
|
|
136
|
+
pre-commit install
|
|
137
|
+
pytest
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Limitations
|
|
141
|
+
|
|
142
|
+
Terraform does not describe the full runtime state of Entra ID (manual role assignments, group memberships, Conditional Access, PIM). Attack paths found from Terraform alone are therefore partial.
|
|
143
|
+
|
|
144
|
+
The 18 KQL detections pass on Azure Data Explorer (`scripts/adx_s10.py`), but the test is partly circular: the events and the rules come from the same Microsoft documentation. It shows that the queries run on the real column names and separate an attack from close normal activity; it does not show that a real tenant emits these values.
|
|
145
|
+
|
|
146
|
+
With `--plan`, resources of remote modules carry the values the plan resolved but no references (a mocked plan has no `configuration`), so a link that goes through a module input is not found.
|
|
147
|
+
|
|
148
|
+
The LLM is optional. On the identity-takeover gap benchmark (`scripts/measure_gaps.py`), no local model tested (qwen3.5:9b, Foundation-Sec-8B-Reasoning) beat a regex over the operations a role grants; the best tied it (3/5, no false positive). Its proposals stay unverified hypotheses and never reach the SARIF output.
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
[Apache-2.0](LICENSE)
|