# AI Security for Builders
<!--
ref: @knowledge/protocols/ai-security-for-builders
type: protocol
triggers: [AI-generated code vulnerabilities, prompt injection attacks, exposed API keys, agent exploitation]
trigger_prompt: When developers are concerned about security risks in AI systems, such as vulnerabilities from AI-generated code or potential exploitation of agents with write access.
version: 2
updated_at: 2026-07-14T21:14:03.835Z
-->

> As AI generates 60%+ of code and agents gain write access to systems, security moves from "nice to have" to existential. The OWASP Top 10 is your baseline.

## The Threat Landscape

- AI-generated code introduces subtle vulnerabilities at scale
- Agents with "write" access can be exploited
- Prompt injection attacks target agent systems
- API keys and secrets exposed through careless AI usage
- OpenClaw-style local agents create new attack surfaces

## The Protocol

### 1. Know OWASP Top 10
- Injection (SQL, command, prompt)
- Broken authentication
- Sensitive data exposure
- XML/JSON external entities
- Broken access control
- Security misconfiguration
- Cross-site scripting (XSS)
- Insecure deserialization
- Known vulnerable components
- Insufficient logging

### 2. Scan Early and Often
- Run vulnerability scans on every deploy
- Use tools like Snyk, Semgrep, or SMP
- Automate security checks in CI/CD
- Never expose API keys in code or prompts

### 3. Agent-Specific Security
- Separate "read" access (analysis) from "write" access (execution)
- Implement checks and balances between agents
- Human-in-the-loop for destructive operations
- Audit trails for all agent actions
- Sandbox agent execution environments

### 4. MCP Server Security
- Vet MCP servers before installation
- Use "Vibe Check" tools for security assessment
- Limit MCP server permissions
- Monitor for unusual tool usage patterns

## Key Principle

> Treat agents like employees with security clearances. Read access for analysis, write access only with authorization and audit trails.

## Appendix

### A. Related Concepts
- Agent Economy Scale — agents in production
- Self-Documenting Code — prevent feature loss

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*