9 views
This guide focuses on AI tool allowlists for production systems, with practical trade-offs for reliability, security, and cost.
An agent that can fetch(url) will eventually fetch http://169.254.169.254/. SSRF defenses are not optional: allowlists, DNS pinning, and egress proxies that block link-local and cloud metadata.
⚡ TL;DR: Default-deny URL tools. Allow only https to known hosts. Resolve DNS yourself and block private/link-local ranges. Force egress through a proxy that strips IMDS.
AI tool allowlists: production guidance
python
# net/allow.py
from urllib.parse import urlparse
import ipaddress, socket
ALLOW_HOSTS = {"api.github.com", "docs.internal.example"}
def assert_safe_url(url: str):
u = urlparse(url)
if u.scheme != "https":
raise ValueError("scheme")
if u.hostname not in ALLOW_HOSTS:
raise ValueError("host")
infos = socket.getaddrinfo(u.hostname, 443)
for info in infos:
ip = ipaddress.ip_address(info[4][0])
if ip.is_private or ip.is_loopback or ip.is_link_local:
raise ValueError("blocked_ip") # ✅ DNS rebinding defense
Egress proxy
nginx
Run agent tasks with careful # block IMDS and RFC1918
deny 169.254.0.0/16;
deny 10.0.0.0/8;
deny 172.16.0.0/12;
deny 192.168.0.0/16;
NO_PROXY — never let the task hit IMDS hop-by-hop.
Tool shape
typescript
export async function httpGet(url: string) {
assertSafeUrl(url);
return fetch(url, { redirect: "error" }); // ❌ no blind redirects
}
Closing checklist
- [ ] HTTPS + host allowlists
- [ ] Resolve + block private IPs
- [ ] Disable automatic redirects or re-validate
- [ ] Egress proxy denying IMDS
- [ ] Unit tests for metadata IPs and rebinding
Series navigation
Day 61: Prompt Injection in Jira, Email, and RAG · Day 63: IAM for Agents: Roles, Not God Keys Last updated September 11, 2026 Related: Day 32: Bedrock Converse API Tool Choice in Production; Day 7: Prompt Contracts: System, Developer, User, Tool; Day 35: Idempotent Tool Calls Against DynamoDB.Watch: 100 Days of AI on YouTube
Short videos from CheatCoders, one AI engineering topic per day.
Most viewed
- Python Decorators Explained: From Simple Wrappers to Production Patterns
- Claude Code vs Cursor vs GitHub Copilot: Choose by Workflow, and Set Up One Repo That Works With All Three
- AI Agent Frameworks in 2025: LangGraph vs CrewAI vs AutoGen vs Raw API
- Python String Methods: Every str Method With Real Production Examples
- Css Animation Performance: Performance-Optimized Motion for Modern UIs
Newly added
- AWS Systems Manager Parameter Store: Hierarchical Runtime Config for Coding Agents
- Amazon Cognito Identity Pools: Federate Coding-Agent Tool Callers Without Long-Lived Keys
- Amazon Athena for Coding Agents: Query Tool Audit Logs and Eval Traces on S3 Without a Warehouse
- AWS Batch for Coding Agents: Parallel Overnight PR Reviews and Long-Running Jobs Without Lambda Timeouts
- Amazon Bedrock Prompt Management: Version and A/B Test Coding-Agent System Prompts
Deep-dive PDF
Get the expanded guide for this post — extra diagrams-style checklists, failure modes, and a production walkthrough. Free when you subscribe to CheatCoders.
Already subscribed? or open the subscribe page.
Discover more from CheatCoders
Subscribe to get the latest posts sent to your email.
