How to Secure LangChain Tools Against Unauthorized Actions
Putting physical authorization locks on every tool an AI agent can call.
Securing LangChain tools requires isolating execution behind an external validation boundary. Exogram wraps tool functions with parameter inspection, rate limits, and role authorization, rejecting malformed or unauthorized tool calls before they execute.
What Actually Happened in the Real World
A developer gave a LangChain agent access to a bash tool for running unit tests. A prompt injection in a user-submitted code snippet tricked the agent into executing a curl command that exfiltrated environment variables to an external server.
Why Polite Prompts Like “Please Don't Do This” Fail
System instructions cannot guarantee an agent will recognize an adversarial payload embedded inside tool input arguments.
The Sub-Millisecond Code Fix
Exogram evaluates tool arguments against a strict whitelist of safe commands and destination endpoints before passing them to the system runtime.
import { ExogramGuard } from '@exogram/sdk';
const guard = new ExogramGuard({
allowedCommands: ['npm test', 'pytest'],
blockedPatterns: [/curl/, /wget/, /rm -rf/]
});
export async function safeBash(command: string) {
guard.validate(command);
return runCommand(command);
}Frequently Asked Questions
Can Exogram block prompt injection inside tool inputs?
Yes. Exogram checks the actual arguments and payloads before execution, preventing injection payloads from triggering side effects.
Related Diagnostic Answers
Comparison Guides
Stop AI Mistakes Before They Execute
Exogram sits directly between your AI model and your tools. Set up in 10 seconds inside Claude, Cursor, ChatGPT, or your own code.