Supply-chain security, capability intelligence, and trust system for AI agents
Project description
Bastion AI
Supply-chain security, capability intelligence, and trust system for AI agents.
Bastion AI protects bot-first ecosystems by detecting malicious or risky skills/plugins/tools, tracking capability drift over time, and producing machine-readable security artifacts (Dynamic AIBOM).
Installation
pip install bastion-ai-security
For JavaScript/TypeScript analysis support:
pip install bastion-ai-security[js]
PyPI: https://pypi.org/project/bastion-ai-security/
Two Ways to Use Bastion
Bastion works for both humans operating from the command line and AI agents acting autonomously.
Path 1: Human-Operated CLI
You install Bastion, run scans yourself, and review results in the terminal or cloud dashboard. This is the traditional security workflow — a developer or security engineer vetting plugins before deployment.
pip install bastion-ai-security
bastion init
bastion scan
You see the results, make decisions, and optionally connect to the cloud dashboard for monitoring and trust scores.
Path 2: AI Agent Integration (MCP Server)
Bastion runs as an MCP (Model Context Protocol) server, letting AI agents like Claude, Cursor, or any MCP-compatible client use it as a built-in security tool. The agent can scan directories, analyze files, and check trust scores autonomously — acting as its own security gate before installing or using third-party plugins.
pip install bastion-ai-security[mcp]
bastion mcp-serve
The AI agent calls Bastion's tools directly through the MCP protocol. No human in the loop required — the agent makes security decisions based on scan results.
Both paths produce the same security artifacts, trust scores, and detection coverage across all 11 capability categories.
Quick Start
Initialize a project
cd your-agent-project
bastion init
This creates a .bastion/ directory with project configuration and prepares for scanning.
Scan for risks
bastion scan
Bastion auto-discovers plugins, skills, and tools in your project and analyzes them across 11 security categories:
- System execution — detects capabilities that allow running arbitrary commands
- Network access — identifies outbound network communication
- Secret/environment access — flags reading of credentials and environment variables
- File system access — detects reading/writing to the local filesystem
- Dynamic code execution — identifies runtime code generation and execution
- Obfuscation patterns — catches attempts to hide malicious intent through encoding
- Sandbox bypass — flags attempts to disable or circumvent safety controls
- Install script risks — detects potentially dangerous installation behaviors
- Hardcoded secrets — finds credentials embedded directly in source code
- Privilege escalation — identifies plugins requesting excessive combined permissions
- Dependency risk — analyzes dependency files for typosquats, unpinned versions, URL/git installs, and non-standard registries
Each finding includes remediation guidance — actionable suggestions for how to fix or mitigate the risk.
For each plugin, the scan also captures:
- Dependencies — third-party libraries imported by the plugin
- Skills — exported functions and classes
- Metadata — description (from docstrings), file count, and lines of code
Scan a specific directory:
bastion scan --path ./my-plugins
OpenClaw SKILL.md Analysis
Bastion has first-class support for OpenClaw skills. When scanning with --openclaw, it analyzes SKILL.md files for dangerous agent instructions, unsafe configuration flags, suspicious install metadata, and skills that instruct agents to download and execute remote code.
bastion scan --openclaw
This directly addresses research findings on skill-based supply chain attacks, where innocent-looking documentation can bundle malicious instructions.
MCP Server (AI Agent Integration)
Bastion can run as an MCP (Model Context Protocol) server, letting AI agents and LLMs use it as a security tool directly.
Install with MCP support:
pip install bastion-ai-security[mcp]
Start the MCP server:
bastion mcp-serve
Or run it directly:
bastion-mcp
The MCP server exposes these tools:
| Tool | Description |
|---|---|
scan_directory |
Scan a directory for plugin/skill security risks |
analyze_file |
Analyze a single file for dangerous capabilities |
get_project_status |
Get current Bastion project configuration |
list_detection_categories |
List all 11 detection categories with descriptions |
check_trust_score |
Check trust score from Bastion Cloud |
get_remediation_guidance |
Get actionable fix suggestions for a capability category |
get_policy |
View the current security policy (allow-list) for a project |
To configure in Claude Desktop or other MCP clients, add to your config:
{
"mcpServers": {
"bastion-security": {
"command": "bastion-mcp"
}
}
}
This allows an AI agent running on your machine to automatically verify plugins before installing them — acting as a security gate in the agent's workflow.
Check project status
bastion status
Shows your project ID, version, baseline status, cloud connection, and verification URL.
Connect to Bastion Cloud
bastion connect
Links your project to Bastion Cloud for continuous monitoring, trust scores, and a security dashboard.
After connecting, the CLI prints a claim URL — click it to link the project to your account on the dashboard. If you're not signed in yet, you'll be prompted to sign in first, and the project will be linked automatically.
Once connected, every bastion scan automatically uploads results to the cloud. No extra flags needed.
Dashboard: https://bastion-ai-hub.replit.app
Share verification with partners
After a scan uploads to the cloud, the CLI prints a verification URL like:
https://bastion-ai-hub.replit.app/verify/abc123...
Share this link with business partners, customers, or integrators. The public verification page shows:
- Trust score and verification status
- Detected capabilities
- Number of scans and plugins analyzed
- Last scan date
No login is required to view a verification page.
How It Works
Plugin Discovery
Bastion automatically discovers plugins using framework-aware heuristics. It recognizes common agent frameworks (OpenClaw, LangChain, AutoGPT, CrewAI, and others) and finds plugins without manual configuration.
Capability Analysis
Each discovered plugin is analyzed using language-appropriate static analysis:
- Python: AST-based analysis
- JavaScript/TypeScript: Parser-based analysis with fallback strategies
- SKILL.md: Structured document analysis for agent instruction risks
Detection Categories
Bastion scans across 11 capability categories at varying severity levels:
| Category | Severity |
|---|---|
| System Execution | Critical |
| Dynamic Code | Critical |
| Obfuscation | Critical |
| Sandbox Bypass | Critical |
| Hardcoded Secret | Critical |
| Privilege Escalation | Critical/High |
| Network Access | High |
| Secret/Env Access | High |
| Install Script Risk | High/Medium |
| Dependency Risk | High/Medium |
| File System Access | Medium |
Privilege Escalation Detection
Bastion automatically flags plugins that combine multiple dangerous capabilities, identifying over-privileged plugins that pose elevated risk.
Drift Detection
On subsequent scans, Bastion compares against the baseline to detect:
- New plugins added since last scan
- Modified plugins with changed capabilities
- Removed plugins no longer present
Generated Artifacts
All artifacts are written to .bastion/:
| File | Description |
|---|---|
security_state.json |
Overall security posture |
capability_surface.json |
All plugin capabilities |
drift_summary.json |
Changes since last scan |
aibom.json |
Dynamic AI Bill of Materials |
events.log.jsonl |
Rolling event log |
baseline.json |
Baseline for drift comparison |
Security Policy (Allow-List)
Bastion supports a security policy file (.bastion/policy.yaml) that lets you acknowledge known capabilities and reduce alert fatigue. Acknowledged findings still appear in reports but are labeled separately and do not trigger CI failure.
bastion policy add my_plugin system_execution --reason "Required for build scripts"
bastion policy list
bastion policy remove my_plugin system_execution
When all Critical/High findings for a project are acknowledged in the policy, bastion scan exits with code 0 — making it safe to use in CI pipelines without false positives from expected behavior.
Dependency Chain Scanning
Bastion analyzes dependency files in your project for supply-chain risks:
- Typosquat detection — flags packages with names suspiciously similar to popular libraries (using Levenshtein distance)
- URL/git installs — identifies dependencies installed from URLs or git repositories instead of official registries
- Unpinned versions — detects dependencies without version pinning that could silently change
- Non-standard registries — flags dependencies pulled from unofficial sources
Supported dependency files: requirements.txt, package.json, setup.py, pyproject.toml, Pipfile.
CI/CD Usage
bastion init
bastion scan --ci
Uses exit codes to signal whether security risks were found, suitable for automated gates. If you use a security policy, acknowledged findings will not cause a non-zero exit code.
Language Support
- Python (
.py) - JavaScript (
.js,.jsx) - TypeScript (
.ts,.tsx) - SKILL.md (OpenClaw skill format)
Troubleshooting
"bastion: command not found"
Make sure the pip install directory is in your PATH:
python3 -m bastion --version
Or:
pip install --user bastion-ai-security
export PATH="$HOME/.local/bin:$PATH"
bastion --version
Scan finds no plugins
If Bastion doesn't find your plugins automatically, point it at the right directory:
bastion scan --path /path/to/your/plugins
Cloud connection issues
Scans work fully offline — results are saved locally in .bastion/ even if the cloud is unreachable.
License
MIT
Project details
Release history Release notifications | RSS feed
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 bastion_ai_security-0.1.8.tar.gz.
File metadata
- Download URL: bastion_ai_security-0.1.8.tar.gz
- Upload date:
- Size: 42.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeb32268ecbf4bb3f86907397425d267eebe20bd6d75bcfab053d09a0024c0b9
|
|
| MD5 |
0087bdd1b2a18b93d3de9d5db4b18470
|
|
| BLAKE2b-256 |
bf25921cf426ac79345d03971118b269d50a65e2d3e56d8b90fd14174bc8af3b
|
File details
Details for the file bastion_ai_security-0.1.8-py3-none-any.whl.
File metadata
- Download URL: bastion_ai_security-0.1.8-py3-none-any.whl
- Upload date:
- Size: 46.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0b70ee98f0edc649f30ae2d3fce69b4422c19d527b61b76ffe01f1bf0f17ed1
|
|
| MD5 |
f9dec0a137c4a14eeda606962ebca8d3
|
|
| BLAKE2b-256 |
12b9a28e8117f1a39887ba71e4d89022581d6657636c4ae2a7dbc89c3a9f2c29
|