← all repositories
cdxiaodong/cain-agent

AI pentesting for the clouds nobody else bothers to cover

Cain is a real-world AI pentesting agent that enforces scope through engineering constraints rather than model self-discipline, with built-in coverage for AWS, Azure, GCP, and the Chinese clouds most tools ignore.

cain-agent
Velocity · 7d
+30
★ / day
star history

What it does Cain runs a deterministic reconnaissance-to-report pipeline for authorized penetration tests against live enterprise assets and cloud environments. It wraps the Claude Agent SDK inside a state machine that treats scope as a hard configuration constraint, not a polite suggestion. The built-in cloud module covers AWS, Azure, GCP, and the major Chinese providers (Aliyun, Tencent, Huawei), testing for IAM privilege escalation, storage exposure, and metadata SSRF.

The interesting bit Instead of hoping the LLM respects boundaries, Cain uses a PreToolUse hook and a read-only toolchain to block out-of-scope or destructive calls before they execute. Discovery and validation run in entirely separate agent sessions so findings cannot self-confirm, and the pipeline supports per-stage model routing so cheap models can handle recon while high-capability models judge vulnerabilities.

Key highlights

  • Structural safety: scope enforcement, credential redaction, and 46 read-only security tools with dangerous-operation circuit breakers.
  • Cloud-native coverage including IAM/RAM privilege-escalation graph analysis for Aliyun and Tencent, plus metadata SSRF across seven providers.
  • Deterministic state machine (recon → test → report) that is crash-resumable and auditable via workspace files.
  • Per-stage backend routing: recon, test, and report can each use different models or providers to optimize cost and capability.
  • Self-built vulnerable-terraform benchmark with four-metric scoring and 44 test files; untested results are explicitly marked rather than guessed.

Verdict Security teams running authorized cloud and web-app assessments should look here, especially if their estate includes Chinese providers. If you are looking for a CTF toy or an unsupervised autonomous hacker, this is explicitly not that.

Frequently asked

What is cdxiaodong/cain-agent?
Cain is a real-world AI pentesting agent that enforces scope through engineering constraints rather than model self-discipline, with built-in coverage for AWS, Azure, GCP, and the Chinese clouds most tools ignore.
Is cain-agent open source?
Yes — cdxiaodong/cain-agent is open source, released under the Apache-2.0 license.
What language is cain-agent written in?
cdxiaodong/cain-agent is primarily written in Python.
How popular is cain-agent?
cdxiaodong/cain-agent has 834 stars on GitHub.
Where can I find cain-agent?
cdxiaodong/cain-agent is on GitHub at https://github.com/cdxiaodong/cain-agent.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.