agentgraph

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: MIT

README

AgentGraph

Attack-path analysis for autonomous AI agents. Discover how agents, MCP tools, identities, secrets, CI/CD and cloud infrastructure connect — and determine what an attacker could reach if an agent is compromised.

What happens if your AI agent gets compromised?

Developer Agent
      │
      ▼
 GitHub MCP
      │
      ▼
 Repository
      │
      ▼
 CI/CD Pipeline
      │
      ▼
 AWS Role
      │
      ▼
 Production

Your agent technically has "just GitHub access." But compromising it may still create a path to production.

AgentGraph finds the path before an attacker does.

Think BloodHound — but for AI agents.

Why

AI agents are increasingly granted access to email, GitHub, Slack, cloud infrastructure, databases, CI/CD, filesystems, MCP servers, and shell environments. Traditional IAM and attack-path tools were designed around humans, machines, and cloud identities — not agents whose tools unlock further identities, secrets, and infrastructure.

Individually, each permission may look reasonable. The risk emerges from relationships between permissions and systems. AgentGraph models those relationships as a graph and calculates transitive attack paths.

Quick start

# Build
go build -o agentgraph ./cmd/agentgraph

# Run against the built-in vulnerable demo environment
./agentgraph demo

Sample output:

AGENTGRAPH

AI Agents                 4
Connected Tools           3
Identities                2
Discovered Resources      17

Critical Attack Paths     8
High-Risk Attack Paths    44
Crown Jewels Exposed      4

Most Critical Path
developer-agent --USES--> github-mcp --CAN_WRITE--> internal-tools
  --TRIGGERS--> production-ci --CONTAINS_SECRET--> aws-deploy-token
  --AUTHENTICATES_AS--> aws-deploy-role --CAN_ADMIN--> customer-database

Then explore:

./agentgraph demo blast-radius finance-agent
./agentgraph demo paths --from finance-agent --crown-jewels
./agentgraph demo explain PATH-0001
./agentgraph demo remediate finance-agent
./agentgraph demo chokepoints

Live discovery: GitHub and AWS connectors

Connectors discover real infrastructure and merge it with your YAML configuration. Node IDs are stable and referenceable — a YAML relationship can point at github:repo:org/repo or aws:role:arn:aws:iam::123:role/deploy before the connector even runs.

GitHub (read-only token, GITHUB_TOKEN or --token):

./agentgraph scan github --owner my-org --save graph.json

Discovers repositories (with your effective permissions: CAN_READ / CAN_WRITE / CAN_ADMIN), Actions workflows, and Actions secret metadata (names only — values are never fetched or stored).

AWS (default credential chain, read-only principal recommended):

./agentgraph scan aws --save graph.json

Discovers IAM roles and their trust chains (who can assume what, including external accounts and wildcard trusts), IAM users, Secrets Manager secret names, S3 buckets, RDS instances, and Lambda execution roles.

Combine everything:

./agentgraph scan github aws --save graph.json

Then analyze or serve the saved graph:

./agentgraph --graph graph.json paths --from my-agent
./agentgraph --graph graph.json blast-radius my-agent
./agentgraph serve --graph graph.json

Web dashboard

./agentgraph serve                    # from agentgraph.yaml
./agentgraph serve --graph graph.json # from a saved scan

Opens an interactive Cytoscape.js graph at http://127.0.0.1:8080 with:

  • Node types color-coded, crown jewels in gold, dangerous edges (CAN_ADMIN / CAN_EXECUTE) highlighted in red
  • Click an agent for its blast radius, crown jewels at risk, and a one-click remediation recommendation
  • Click any path to highlight it across the graph

REST API (same data the dashboard uses):

GET /api/v1/graph
GET /api/v1/agents
GET /api/v1/agents/{id}/blast-radius
GET /api/v1/agents/{id}/remediations
GET /api/v1/paths?from=agent&to=target&crown_jewels=true

Model your own environment

./agentgraph init          # creates a starter agentgraph.yaml
./agentgraph scan          # loads it and prints the security dashboard

Configuration is a single YAML file describing agents, tools, identities, secrets, and infrastructure — plus the relationships between them:

agents:
  - id: finance-agent
    metadata:
      internet_access: true

mcp_servers:
  - id: github-mcp

repositories:
  - id: payments-repository
    metadata:
      environment: production

cloud_roles:
  - id: aws-deploy-role
    metadata:
      privilege: admin

databases:
  - id: production-database
    criticality: 95

crown_jewels:
  - production-database

relationships:
  - { source: finance-agent,      target: github-mcp,         type: USES }
  - { source: github-mcp,         target: payments-repository, type: CAN_WRITE }
  - { source: payments-repository, target: production-ci,       type: TRIGGERS }
  - { source: production-ci,       target: aws-deploy-role,     type: CAN_ASSUME }
  - { source: aws-deploy-role,     target: production-database, type: CAN_ACCESS }

Run ./agentgraph blast-radius finance-agent and you get:

finance-agent

Risk                       CRITICAL
Exposure Score             85

Direct access            Indirect access
  MCP_SERVER       2       SECRET          3
  IDENTITY         1       DATABASE        2
                          CLOUD_ROLE      1
                          ...

Reachable Nodes            17
Secrets                    3
Highest Privilege          admin

Critical Paths             4
Crown Jewels at Risk       customer-database, payment-signing-key, ...

CLI reference

Command Description
agentgraph init Create a starter agentgraph.yaml
agentgraph scan Load config and print the security dashboard
agentgraph scan [github|aws] Load config and/or run connectors
agentgraph serve Web dashboard + REST API
agentgraph agents List agents with tool/path/risk summaries
agentgraph paths [--from A] [--to B] [--crown-jewels] Enumerate attack paths
agentgraph path shortest --from A --to B Shortest attack path
agentgraph blast-radius <agent> What a compromised agent could reach
agentgraph explain <path-id> Why a path exists, with score breakdown
agentgraph remediate <agent> The permission removal that kills the most paths
agentgraph chokepoints Nodes appearing across the most attack paths
agentgraph export [--out file.json] Export attack paths as JSON
agentgraph demo <command> Run any command against the demo environment

How it works

Connectors (YAML static, GitHub, AWS)
        │
        ▼
Normalization (nodes + edges, secret redaction, assembler merge)
        │
        ▼
Graph Store (in-memory; snapshots via --save/--graph)
        │
        ├── Paths Engine     depth-limited enumeration, cycle prevention,
        │                    confidence filtering, BFS shortest path
        ├── Risk Engine      explainable 0–100 scoring per path
        ├── Blast Radius     direct/indirect reach, crown jewels,
        │                    highest privilege, exposure score
        ├── Remediation      edge-removal optimizer, choke-point analysis
        └── API / Web        REST endpoints, Cytoscape.js dashboard

Key properties

  • Every edge carries a confidence (0–1); path confidence is the product.
  • Every path is explainable: agentgraph explain shows the full risk factor breakdown.
  • Secret values are never stored — only metadata (type, location, provider). The loader actively redacts and warns on forbidden fields.
  • Deterministic path IDs (PATH-0047) are stable across commands.

Risk scoring model (additive, scaled by path confidence, 0–100):

+30  target criticality (max)
+25  privilege level of highest-risk step (max)
+20  production access anywhere on the path
+15  execution / admin capability
+10  crown-jewel target
 +5  internet-exposed agent
 -5  human approval required
 -1  per hop beyond 3 (indirect paths are less reliable)

80–100 CRITICAL   60–79 HIGH   40–59 MEDIUM   20–39 LOW   0–19 INFO

What AgentGraph is not

  • Not a vulnerability scanner, EDR, CSPM, or prompt scanner
  • Not a replacement for BloodHound (Active Directory)
  • It does not exploit anything — it models potential paths and relationships, and it never needs (or stores) secret values

Development

make build     # build ./bin/agentgraph
make test      # run the unit test suite
make vet       # go vet
make fmt       # gofmt
make demo      # build + run the demo scan

Or plain Go: go build ./cmd/agentgraph, go test ./...

Repository layout
cmd/agentgraph/            CLI entry point
internal/graph/            node/edge model, store, assembler, snapshots
internal/paths/            path enumeration + shortest path
internal/risk/             explainable risk scoring
internal/blast/            blast-radius + agent exposure analysis
internal/remediation/      remediation optimizer + choke points
internal/config/           YAML static connector (secret redaction)
internal/connectors/       GitHub + AWS live discovery connectors
internal/api/              REST API + embedded web dashboard
internal/cli/              CLI commands + embedded demo environment

Roadmap

  • Phase 0 — Graph prototype ✅ (model, import, paths, blast radius, risk, remediation, choke points, CLI, demo)
  • Phase 1 — MVP ✅ (GitHub connector, web dashboard + REST API, graph snapshots)
  • Phase 2 — Cloud paths ✅ (AWS connector: IAM trust chains, Secrets Manager, S3, RDS, Lambda)
  • Phase 3 — minimum-cut remediation, least-privilege suggestions
  • Phase 4 — graph snapshots history, drift, historical diff
  • Phase 5 — Entra ID, Kubernetes, GitLab, Slack, Active Directory

Contributing

Issues and PRs welcome. Connector contributions are especially valuable — connectors implement a small interface and don't require touching the graph engine.

License

MIT

Directories

Path Synopsis
cmd
agentgraph command
Command agentgraph is the AgentGraph CLI: attack-path analysis for autonomous AI agents.
Command agentgraph is the AgentGraph CLI: attack-path analysis for autonomous AI agents.
internal
api
Package api implements the AgentGraph REST API and web dashboard (PRD sections 60 and 29).
Package api implements the AgentGraph REST API and web dashboard (PRD sections 60 and 29).
blast
Package blast implements blast-radius and agent-exposure analysis (PRD sections 11, 17, and 25).
Package blast implements blast-radius and agent-exposure analysis (PRD sections 11, 17, and 25).
cli
Package cli implements the agentgraph command-line interface.
Package cli implements the agentgraph command-line interface.
config
Package config implements the static configuration connector: importing a manually defined architecture from YAML into the graph (PRD section 21).
Package config implements the static configuration connector: importing a manually defined architecture from YAML into the graph (PRD section 21).
connectors
Package connectors defines the discovery interface implemented by every AgentGraph integration (PRD section 34).
Package connectors defines the discovery interface implemented by every AgentGraph integration (PRD section 34).
connectors/aws
Package aws implements the AWS connector: read-only discovery of IAM roles and trust chains, IAM users, Secrets Manager secret metadata, S3 buckets, RDS instances, and Lambda functions (PRD section 21).
Package aws implements the AWS connector: read-only discovery of IAM roles and trust chains, IAM users, Secrets Manager secret metadata, S3 buckets, RDS instances, and Lambda functions (PRD section 21).
connectors/github
Package github implements the GitHub connector: read-only discovery of repositories, workflows, secrets metadata, and the permissions of the authenticated principal (PRD sections 21 and 55).
Package github implements the GitHub connector: read-only discovery of repositories, workflows, secrets metadata, and the permissions of the authenticated principal (PRD sections 21 and 55).
graph
Package graph implements the AgentGraph normalized node and edge models and the in-memory graph store.
Package graph implements the AgentGraph normalized node and edge models and the in-memory graph store.
paths
Package paths implements attack-path enumeration and shortest-path search over the AgentGraph graph model.
Package paths implements attack-path enumeration and shortest-path search over the AgentGraph graph model.
remediation
Package remediation implements choke-point analysis and permission removal recommendations (PRD sections 15 and 16).
Package remediation implements choke-point analysis and permission removal recommendations (PRD sections 15 and 16).
risk
Package risk implements explainable attack-path risk scoring (PRD sections 13 and 14).
Package risk implements explainable attack-path risk scoring (PRD sections 13 and 14).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL