This release is a pre-release and may not be stable for production use.
SafeAI — Static AI Capability & Risk Analyzer
SafeAI is a static analysis tool that scans AI application source code for security risks, capability exposure, and governance gaps. It runs entirely offline, never executes agents or calls LLMs, and integrates into CI/CD pipelines.
🌐 safeai-analyzer.ikaruscareer.com — project landing page
Know Your Agent (KYA)
SafeAI now turns static scan results into a private, historical inventory of AI agents and their findings.
Why SafeAI?
Traditional application security tools (SAST, SCA, IaC scanning) are not designed for AI agent systems. AI applications introduce new risk surfaces:
- Prompt injection — untrusted input flows into model prompts
- Agent tool misuse — agents with filesystem, shell, or database access
- Capability sprawl — frameworks expose capabilities without visibility
- MCP exposure — Model Context Protocol endpoints and tools
- Governance gaps — missing authentication, permissions, audit trails
SafeAI fills this gap by analyzing frameworks, agents, tools, capabilities, and MCP integrations at rest—before deployment.
SafeAI analyzes AI applications without executing them, helping developers discover capabilities, identify potential risks, and improve governance early in the software lifecycle.
Designed to be lightweight, explainable, and community-driven, SafeAI aims to become an open foundation for AI capability and risk analysis.
SafeAI sits before runtime guardrails and red-teaming tools in the security lifecycle. It scans agent source code at commit time — detecting framework-specific capabilities, MCP misconfigurations, and prompt injection patterns — before you ever deploy an agent to staging. It does not replace runtime tools (Microsoft AGT), evaluation frameworks (LangSmith, DeepEval), or red-teaming scanners (Promptfoo, Garak). It complements them: find the risk in code first, then validate at runtime.
Key Features
| Feature | Description |
|---|---|
| Framework Detection | Detects and parses 15 AI agent frameworks (AST + config + regex, no mutual exclusion) |
| Tool Identity & Access Modes | Capabilities attributed to named tools (agent / MCP server / skill / tool / workflow node) on an access scale none < read < write < mutate < execute; inferred modes are flagged, never overstated |
| Capability Discovery | Maps 19 capability categories (shell, filesystem, network, database, memory, MCP, ...) with evidence, confidence, and provenance |
| Capability Escalation Detection | Per-tool authority diffs between scans (new shell, read→write widening, new MCP server, removed approval gate, ...) — 14 rules, including gating-aware subsumption |
| AI Risk Analysis | Categorizes findings into 7 risk categories with weighted trust scoring (0–100) |
| Prompt Risk Analysis | Detects injection patterns, delimiter issues, system leak, role override |
| Component-Level Analysis | Skills, prompt files, tool definitions, model configurations, workflow templates |
| Deep Claude Code Analysis | Structural analysis of .claude/settings.json, permissions, slash commands, subagents, hooks, .mcp.json |
| MCP Analysis | Discovers MCP servers, clients, tools, resources, and validates configuration |
| Data Leakage Detection | Flags hardcoded secrets, tokens, and API keys (redacted in all outputs) |
| KYA Shared Registry | Append-only SQLite registry of scan-derived agent records, shared org-wide; list/show/history/diff/export |
| Baseline & Escalation Gating | --fail-on-new for new/regressed findings, --fail-on-escalation for authority changes, --pr-comment PR summaries |
| Policy-as-Code & Suppressions | allow/warn/require_review/deny policy with selectors; required-reason suppressions |
| Assurance Boundary | Every scan states exactly what it did and could not verify — never a fixed disclaimer |
| CI/CD Integration | SARIF 2.1.0 output, exit codes, GitHub Actions workflow included |
| Multi-Format Reports | Terminal, JSON, SARIF 2.1.0, HTML, canonical KYA manifest, PR comment |
| Cross-File Analysis | Import graph, symbol resolution, and project graph |
| Confidence-Arbitrated Parsing | Multiple parsers per file, merged with provenance |
How It Works
Source Code
│
▼
File Collection — Python, YAML, JSON, .prompt, and .claude configs;
prunes VCS, caches, oversized files, and SafeAI's own artifacts
│
▼
Framework Detection — 15 parsers (AST + config + regex), all run on all files;
import graph and dependency manifests
│
▼
Static Analysis — semantic docs, component extraction, capability / prompt /
data-leakage / MCP / Claude Code analyzers
│
▼
Capability Mapping — per-tool identity (agent, MCP server, skill, tool,
workflow node) + access modes (read < write < mutate < execute)
│
▼
Risk Rules — rule engine with severity, confidence, provenance, stable fingerprints
│
▼
Trust Score — deterministic 0–100 score across 7 weighted risk categories
│
▼
KYA Pipeline — finding normalization, suppressions, baseline (new/regressed),
policy-as-code, capability escalation diff
│
▼
Registry & Reports — shared SQLite registry; terminal, JSON, SARIF 2.1.0, HTML,
canonical manifest, PR comment
Supported Frameworks
| Framework | Detection | Discovery | Capability Analysis | Risk Analysis | Status |
|---|---|---|---|---|---|
| LangGraph | ✔ | Partial | Partial | Partial | Partial |
| CrewAI | ✔ | Partial | Partial | Partial | Partial |
| LangChain | ✔ | Partial | Partial | Partial | Partial |
| Semantic Kernel | ✔ | Partial | Partial | Partial | Partial |
| OpenAI Agents SDK | ✔ | Partial | Partial | Partial | Partial |
| Microsoft Agent Framework | ✔ | Partial | Minimal | Minimal | Experimental |
| Azure AI Foundry | ✔ | Minimal | Minimal | Minimal | Experimental |
| Bedrock Agent | ✔ | Minimal | Minimal | Minimal | Experimental |
| Claude Code | ✔ (deep) | Deep | Partial | Partial | Partial |
| Google ADK | ✔ | Partial | Minimal | Minimal | Experimental |
| Mastra | ✔ | Partial | Minimal | Minimal | Experimental |
| Haystack | ✔ | Partial | Minimal | Minimal | Experimental |
| LlamaIndex | ✔ | Partial | Minimal | Minimal | Experimental |
| Dify | ✔ | Minimal | Minimal | Minimal | Experimental |
| n8n | ✔ | Partial | Minimal | Minimal | Experimental |
Framework Support Details
- LangGraph — detects
StateGraph,add_edge,bind_tools, nodes, models - CrewAI — detects
Agent,Task, tools, models - LangChain — detects
AgentExecutor,Chain,Tool,PromptTemplate, models - Semantic Kernel — detects
Kernel.invoke, plugins, functions, skills, memory - OpenAI Agents SDK — detects
Agent, tools, handoffs, MCP references - Microsoft Agent Framework — detects
AgentClient, tools, workflows, Azure models - Azure AI Foundry — detects YAML configurations with Azure resources
- Bedrock Agent — detects JSON configurations with Bedrock resources
- Claude Code — structural analysis of
.claude/settings.json, permission grants,.mcp.json, slash commands, subagent definitions, and lifecycle hooks - Google ADK — detects ADK agent, workflow, tool, and model patterns
- Mastra — detects Mastra agents, workflows, tools, and model references
- Haystack — detects Haystack pipelines, agents, tools, and retrievers
- LlamaIndex — detects agents, tools, indexes, and model references
- Dify — detects Dify workflow and agent configuration files
- n8n — detects n8n workflow exports, nodes, and connections
Maturity is on the scale defined in FRAMEWORK_SUPPORT.md:
Partial = reliable detection and discovery with capability/risk analysis over
common patterns; Experimental = detection and basic artifact discovery with
limited framework-specific analysis. No framework is rated fully Supported
yet — SafeAI is in early preview and deliberately does not overclaim coverage.
Supported Capabilities
SafeAI fingerprints capabilities at the framework object level and via fallback regex patterns. Each capability includes evidence, confidence score, resolved definition, and provenance.
| Capability | Category | Risk Impact |
|---|---|---|
| Shell Execution | Shell | Command injection, host compromise |
| Filesystem Access | Filesystem | Data exfiltration, file tampering |
| Browser Automation | Browser | UI-based attacks, credential theft |
| Planning / Orchestration | Planner | Autonomous decision chain risk |
| Agent Delegation | Delegation | Unchecked sub-agent authority |
| Memory / Checkpoint | Memory | Data retention across sessions |
| RAG / Retrieval | RAG | Document exfiltration, prompt injection via documents |
| GitHub Integration | GitHub | Repository access, secret leakage |
| Slack Integration | Slack | Channel monitoring, message injection |
| Email Integration | Phishing, data exfiltration | |
| Database Access | Databases | SQL injection, data breach |
| Cloud Services | Cloud | Cloud resource abuse, cost escalation |
| External APIs | External APIs | Third-party data exfiltration |
| MCP Services | MCP | Exposed endpoints, unauthorized tool access |
| Human Approval | Human Approval | Approval bypass risk |
| Multi-Agent | Multi-Agent | Delegation-based privilege escalation |
| Container | Container | Container orchestration abuse (Docker, Kubernetes) |
| Collaboration | Collaboration | Cross-system coordination risk |
| Untrusted Input | Untrusted Input | Injection surface into agent pipelines |
Note: A capability is detected wherever the evidence lives — through a framework adapter, a direct pattern detector (for example Docker, Kubernetes, S3, Slack, Jira, browser automation, GCP), or MCP configuration analysis. Capabilities that only MCP configuration exposes today (e.g. email, human approval gates) are still flagged — the tool is reported with an unattributed identity rather than a guessed owner.
Know Your Agent (KYA) — Shared Registry
Every scan automatically builds a private "Know Your Agent" registry of
scan-derived agent records — no server, no account, no network call, no
source upload. Scans from every project accumulate in one shared SQLite
database (SAFEAI_REGISTRY env var or ~/.safeai/registry.db), so
safeai registry list shows the whole organization's agents from any folder.
safeai scan . # scan + accumulate into the shared registry
safeai scan . --manifest safeai-manifest.json # also write the canonical KYA manifest
safeai scan . --html report.html # interactive HTML report (risk gauge, escalations)
safeai registry list # agents/workflows from every scanned project
safeai registry list --format html > registry.html # shareable HTML inventory
safeai registry show <agent-id> # latest KYA record
safeai registry history <agent-id> # all scans for an agent
safeai registry diff <agent-id> --from previous --to latest
safeai registry export --format json --output inventory.json
safeai registry export --format html --output inventory.html
What you get on the first run:
- A static scan ran successfully.
- The shared registry was initialized (
SAFEAI_REGISTRYor~/.safeai/registry.db). - One or more KYA agent records were created with stable identities.
- Findings carry confidence, provenance, remediation, and stable fingerprints.
- No source code or secrets are uploaded or stored in output artifacts.
KYA records static evidence, not runtime truth. It answers "what does the source/configuration say this agent can do?" — never "what is this agent doing in production?" See REGISTRY.md, KYA_MANIFEST.md, and LIMITATIONS.md.
CI note: registry persistence is auto-disabled for bare CI jobs (the CI
env var). Use --registry "$RUNNER_TEMP/registry.db", set SAFEAI_REGISTRY
to a shared path, or use --no-registry for ephemeral scans.
Installation
Requirements
- Python 3.11, 3.12, or 3.13
- PyYAML (for YAML configuration parsing)
Install from source
git clone https://github.com/ikaruscareer/SafeAI.git
cd SafeAI
pip install -e .
Install development dependencies
pip install -e ".[dev]"
CLI Usage
python -m safeai scan <directory> [options]
python -m safeai registry <subcommand> [options]
Options
| Option | Default | Description |
|---|---|---|
directory |
required | Path to scan |
--sarif |
report.sarif |
SARIF output path (empty string to skip) |
--json |
— | JSON output path |
--html |
— | HTML report output path |
--manifest |
— | Canonical KYA manifest output path (safeai-manifest.json) |
--baseline |
— | Prior manifest/report for new/existing comparison |
--fail-on-new |
off | With --baseline: fail only on new/regressed findings |
--policy |
.safeai/policy.yml |
Policy-as-code YAML file |
--suppressions |
.safeai/suppressions.yml |
Suppressions YAML file |
--registry |
shared (SAFEAI_REGISTRY/~/.safeai/registry.db) |
Registry database path |
--no-registry |
off | Skip registry persistence |
--strict-registry |
off | Fail the scan if registry persistence fails |
--pr-comment |
— | Write a reviewer-facing Markdown summary of capability escalations to this path (never posted anywhere) |
--pr-comment-stdout |
off | Print the PR comment Markdown to stdout |
--fail-on-escalation |
— | Fail if a capability escalation at or above critical, high, or medium is detected (requires --baseline) |
--rules |
built-in | Custom rules directory |
--fail-on |
critical |
Exit code threshold: critical, high, medium |
--verbose |
— | Enable verbose output |
Exit Codes
| Code | Condition |
|---|---|
| 0 | No findings at or above threshold; policy outcome not deny |
| 1 | Finding at or above threshold, or policy outcome deny |
| 2 | Operational error (e.g. --strict-registry persistence failure) |
Suppressed findings never trigger exit code 1. With --fail-on-new, only
findings classified new or regressed against the baseline are gated.
Common 1.4 Workflows
# canonical manifest + baseline seed
python -m safeai scan . --manifest safeai-manifest.json
# CI/PR scan: fail only for new or regressed findings
python -m safeai scan . --baseline safeai-manifest.json --fail-on-new --fail-on high
# CI/PR scan: fail on capability escalations and render a PR comment
python -m safeai scan . --baseline safeai-manifest.json \
--fail-on-escalation high --pr-comment comment.md
# inspect the shared KYA registry
python -m safeai registry list
python -m safeai registry show <agent-id>
python -m safeai registry history <agent-id>
python -m safeai registry diff <agent-id> --from previous --to latest
python -m safeai registry export --format json --output safeai-kya-inventory.json
Example Output
Terminal
SafeAI Scan Summary
Files: 12
Frameworks: langgraph, crewai
MCP assets: 2
Overall AI Risk Score: 73
critical: 1
high: 3
medium: 5
Findings:
[critical] app.py:10 - Untrusted input interpolated into prompt
[high] app.py:22 - Capability detected: shell_execution
[high] mcp.json:1 - MCP configuration does not define authentication
Example: LangGraph agent with MCP
{
"Framework": "LangGraph",
"Capabilities": ["Planner", "Memory", "Filesystem", "MCP"],
"Risk Score": 73,
"Findings": 9,
"Critical": 1,
"High": 3
}
CI/CD Integration
GitHub Actions
A workflow is included at .github/workflows/ci.yml. To use in your project:
jobs:
safeai-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install SafeAI
run: |
pip install -e .
- name: Run scan
run: |
python -m safeai scan . \
--sarif results.sarif \
--html report.html \
--manifest safeai-manifest.json \
--no-registry
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
GitLab CI
safeai-scan:
image: python:3.12
script:
- pip install -e .
- python -m safeai scan . --sarif results.sarif --html report.html --no-registry
artifacts:
paths:
- results.sarif
- report.html
Azure DevOps
- task: PythonScript@0
inputs:
scriptSource: 'inline'
script: |
import subprocess
subprocess.run(["pip", "install", "-e", "."])
subprocess.run(["python", "-m", "safeai", "scan", ".", "--sarif", "$(Build.ArtifactStagingDirectory)/results.sarif", "--no-registry"])
Capability escalation in CI
A capability escalation is a change between two scans where a tool gains
more authority than it had before — a new shell capability, a filesystem
access widening from read to write, a new MCP server, an approval gate
being removed, and so on (see RULES_REFERENCE.md and KYA_MANIFEST.md
for the full rule list). Reviewing these on every pull request is more
targeted than reviewing every finding, because most findings on a mature
codebase are pre-existing and already accepted; an escalation is new by
definition.
--fail-on-escalation gates the scan on escalation severity, and
--pr-comment writes a short Markdown summary you can post as a PR
comment. SafeAI itself never posts anything anywhere and makes no network
calls of any kind — generating the comment and publishing it are two
separate steps, and the second one is entirely up to your CI workflow.
name: safeai-escalation-check
on:
pull_request:
permissions:
contents: read
pull-requests: write
jobs:
safeai-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install SafeAI
run: pip install -e .
- name: Fetch baseline manifest from the base branch
run: |
git fetch origin "${{ github.event.pull_request.base.ref }}" --depth=1
git show "origin/${{ github.event.pull_request.base.ref }}:safeai-manifest.json" \
> safeai-manifest.json || echo '{}' > safeai-manifest.json
- name: Run scan
run: |
safeai scan . \
--baseline safeai-manifest.json \
--pr-comment comment.md \
--fail-on-escalation high
- name: Post or update PR comment
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment "${{ github.event.pull_request.number }}" \
--edit-last --body-file comment.md \
|| gh pr comment "${{ github.event.pull_request.number }}" \
--body-file comment.md
The gh pr comment --edit-last call updates SafeAI's own previous comment
in place on repeat pushes, rather than adding a new one each time; it fails
when there is no previous comment to edit (for example, on the first push),
so the fallback plain gh pr comment handles that case. The --fail-on-escalation
step runs before the comment step so the workflow's exit code still reflects
the scan outcome; if: always() on the comment step makes sure the comment
is posted even when the scan step fails the job.
SARIF Integration
SafeAI outputs SARIF 2.1.0 format, compatible with GitHub Advanced Security, Azure DevOps, and other SARIF-compliant tools.
Roadmap
See ROADMAP.md for the detailed roadmap.
- Completed in 1.3: KYA manifest, baseline/new-regressed gating, suppressions, policy-as-code, local SQLite registry, registry CLI.
- Completed in 1.4 (beta): tool-centric capability model (tool identity
- access modes), 14 capability escalation rules, capability diff v2, deep Claude Code analysis, PR comment + CI context, assurance boundary, registry schema v2, shared org-wide registry default.
- Next focus: adapter depth improvements, governance signal detection, richer dataflow/context precision, and optional enterprise-scale workflows.
License
SafeAI is released under the Apache 2.0 License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file safeai_static_analyzer-1.4.0b0.tar.gz.
File metadata
- Download URL: safeai_static_analyzer-1.4.0b0.tar.gz
- Upload date:
- Size: 190.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be7c174164af44c6be7e257dbfd2d208d9e80d9222882f138b43c11f3808784e
|
|
| MD5 |
e0eb0c3cbd656d2c0ed57ee83f2e5f63
|
|
| BLAKE2b-256 |
58ba483996c8704910c0b8a2c648b44f779f027be28785b31c4ad9897ddcd75a
|
Provenance
The following attestation bundles were made for safeai_static_analyzer-1.4.0b0.tar.gz:
Publisher:
pypi-publish.yml on ikaruscareer/SafeAI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
safeai_static_analyzer-1.4.0b0.tar.gz -
Subject digest:
be7c174164af44c6be7e257dbfd2d208d9e80d9222882f138b43c11f3808784e - Sigstore transparency entry: 2425367816
- Sigstore integration time:
-
Permalink:
ikaruscareer/SafeAI@af442ba1aa0d04a24001a96c016ad2a394120e77 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ikaruscareer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@af442ba1aa0d04a24001a96c016ad2a394120e77 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file safeai_static_analyzer-1.4.0b0-py3-none-any.whl.
File metadata
- Download URL: safeai_static_analyzer-1.4.0b0-py3-none-any.whl
- Upload date:
- Size: 194.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3564f6c31dc29ea8bc1d49dfa6e603b4df4e9f51bcbd75e11329ec9f8651b399
|
|
| MD5 |
cbd918e7dff68dbd39f2337bb9198751
|
|
| BLAKE2b-256 |
69c012de4a57d8295e746afa2c6bceafea258d0236c39d7346cb242a27b7d33f
|
Provenance
The following attestation bundles were made for safeai_static_analyzer-1.4.0b0-py3-none-any.whl:
Publisher:
pypi-publish.yml on ikaruscareer/SafeAI
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
safeai_static_analyzer-1.4.0b0-py3-none-any.whl -
Subject digest:
3564f6c31dc29ea8bc1d49dfa6e603b4df4e9f51bcbd75e11329ec9f8651b399 - Sigstore transparency entry: 2425368220
- Sigstore integration time:
-
Permalink:
ikaruscareer/SafeAI@af442ba1aa0d04a24001a96c016ad2a394120e77 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ikaruscareer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@af442ba1aa0d04a24001a96c016ad2a394120e77 -
Trigger Event:
workflow_dispatch
-
Statement type: