惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
B
Blog
P
Proofpoint News Feed
美团技术团队
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
有赞技术团队
有赞技术团队
小众软件
小众软件
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
罗磊的独立博客
L
LangChain Blog
GbyAI
GbyAI
腾讯CDC
T
The Blog of Author Tim Ferriss
Microsoft Security Blog
Microsoft Security Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Built a Runtime Governance Tool for AI Agents — Here's ...
Anshuman Kum · 2026-05-08 · via DEV Community

Your LangChain agent just ran rm -rf /. It was supposed to list files.

This isn't a hypothetical. AI agents call tools — shell commands, database queries, payment APIs, file operations. Every tool call is a potential security incident. And right now, most agents have zero runtime enforcement.

I built ShadowAudit to fix this. It's a deterministic, offline-first governance layer that sits between your agent and its tools. If a call exceeds your risk threshold, it's blocked. No LLM calls. No cloud dependencies. No API keys.

pip install shadowaudit

Enter fullscreen mode Exit fullscreen mode

The Problem: Agents Are Unguarded

When you build an AI agent, you give it tools. A shell tool. A database tool. A payment API tool. The agent decides which tool to call and with what parameters. That's the whole point — autonomy.

But autonomy without guardrails is negligence.

What the agent should do What the agent might do
ls -la /var/log rm -rf /var/log
SELECT * FROM users WHERE id=123 DROP TABLE users
transfer $10 to vendor transfer $10,000 to unknown_account

Current solutions fall short:

  • Prompt engineering — "Please don't do anything dangerous." Agents ignore this.
  • LLM-based guardrails — Probabilistic, slow, expensive, requires API calls.
  • Human-in-the-loop — Doesn't scale. You can't review 10,000 agent decisions per hour.

What you need is deterministic, runtime enforcement that works offline and blocks dangerous calls before they execute.

What ShadowAudit Does

Agent → ShadowAudit Gate → Tool (allowed)
                         → Blocked (AgentActionBlocked raised)

Enter fullscreen mode Exit fullscreen mode

ShadowAudit evaluates every tool call against a risk taxonomy. If the risk score exceeds the threshold, the call is blocked. The decision is logged. The agent's behavioral state is updated.

5 Lines of Code

from langchain.tools import ShellTool
from shadowaudit.framework.langchain import ShadowAuditTool

safe_shell = ShadowAuditTool(
    tool=ShellTool(),
    agent_id="ops-agent-1",
    risk_category="command_execution",
)

safe_shell.run("ls -la")     # ✅ Allowed
safe_shell.run("rm -rf /")   # ❌ AgentActionBlocked raised

Enter fullscreen mode Exit fullscreen mode

Same interface as the original tool. Drop-in replacement. Zero behavior change for safe calls.

CLI for CI/CD

# Scan your codebase for ungated agent tools
shadowaudit check ./src

# Block deployments if high-risk tools are ungated
shadowaudit check ./src --fail-on-ungated

# Generate a professional HTML assessment report
shadowaudit assess ./src --taxonomy financial --compliance

# Replay agent traces through the safety gate
shadowaudit simulate --trace-file agent_trace.jsonl --compare

Enter fullscreen mode Exit fullscreen mode

Drop shadowaudit check --fail-on-ungated into your CI pipeline. If someone commits an ungated shell tool, the build fails.

Architecture: Deterministic, Not Probabilistic

Every AI safety tool today uses LLMs to evaluate risk. That's slow, expensive, and non-deterministic — the same input can produce different outputs.

ShadowAudit uses keyword-based scoring with pluggable strategies:

  1. Taxonomy lookup — finds risk category config (keywords, threshold delta, severity)
  2. Scoring — pluggable scorer computes risk score from payload content
  3. Threshold comparison — score vs. taxonomy delta determines pass/fail
  4. FSM transition — fail-closed state machine: anything not an explicit pass is a block
  5. Audit log — decision recorded with timestamp, agent ID, payload hash, and reason
  6. State update — K (trust) and V (velocity) metrics updated for adaptive scoring

This is auditable. Reproducible. Explainable. The kind of thing compliance auditors actually accept.

Why Offline-First Matters

ShadowAudit works fully offline. SQLite-backed state. No Redis. No cloud. No API keys.

This matters because:

  • Banks run agents inside air-gapped VPCs. They can't call external APIs.
  • Healthcare has HIPAA constraints. Agent data can't leave the network.
  • Defense contractors work in classified environments. Zero external connectivity.
  • Legal teams block any tool that sends data to third parties.

If your governance tool requires an internet connection, you've already lost these customers.

Pre-Built Taxonomies

ShadowAudit ships with three starter taxonomies:

Taxonomy Risk Categories Example Keywords
General shell execution, file operations, network calls rm, curl, chmod, wget
Financial payments, withdrawals, PII access, account modifications transfer, withdraw, ssn, account_number
Legal privilege waiver, regulatory filings, client data access waive, settle, attorney_client, file_motion

Each taxonomy has tuned thresholds. You can build custom ones interactively:

shadowaudit build-taxonomy

Enter fullscreen mode Exit fullscreen mode

Framework Support

Framework Status
LangChain ✅ First-class adapter
CrewAI ✅ First-class adapter
AutoGen 🔜 Next
OpenAI Agents SDK 🔜 Planned

Both adapters use duck typing — they work with any tool that has name, description, and run(). You don't need the framework installed for the adapter to work.

The Numbers

  • 133 tests, 100% pass rate
  • Zero flaky tests — deterministic by design
  • ruff + mypy clean — strict linting from day one
  • MIT licensed — use it, modify it, build on it
  • Python 3.10+ — modern Python with no legacy baggage

What's Next

ShadowAudit is in alpha (v0.3.2). The core gate, CLI, framework adapters, and assessment tools are functional and tested. Here's the roadmap:

  • 🔜 AutoGen adapter
  • 🔜 Behavioral anomaly detection — pattern detection across sessions
  • 🔜 Pro dashboard — team-level visibility, compliance reports, alerting
  • 🔜 More taxonomies — healthcare, defense, e-commerce

Try It

pip install shadowaudit

Enter fullscreen mode Exit fullscreen mode


AI agents are the next attack surface. Don't wait for an incident to start governing them.

Built by Anshuman Kumar. MIT licensed. Works offline.