ai-agent-security

A security guide for AI agents—software that follows instructions and can use tools or data. It covers threats such as prompt injection, data leaks, unsafe code execution, unauthorized access, and compliance issues.

In plain words
What is it for?
Use it to assess and strengthen AI-agent security across inputs, sensitive information, code execution, permissions, data sources, and audits.
Why use it?
It helps identify and reduce risks when an AI system handles sensitive data or can run code.

Skill for Claude CodeCodexCursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/programmeranthony/expert-coding-harness/ai-agent-security
Any agent
npx skills add ProgrammerAnthony/Expert-Coding-Harness --skill ai-agent-security
Clone the repo
git clone --depth 1 https://github.com/ProgrammerAnthony/Expert-Coding-Harness

Made for: Claude Code, Codex, Cursor.

Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,450 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00039 $0.03450
Opus 5 $0.00019 $0.01725
Sonnet 5 $0.00008 $0.00690
Haiku 4.5 $0.00004 $0.00345

Measured 2d ago against content hash 0050c5902fdc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ai-agent-security scanned grade A with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

r'(curl|wget).*http.*\|.*sh',

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

result = subprocess.run(
.cursor/skills/ai-agent-security/SKILL.md · 400 lines

How it starts

The opening of the file, as written. The whole thing — 400 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AI Agent 安全开发最佳实践

本技能基于生产级AI Agent防护方案整理,覆盖AI系统全生命周期的安全风险防控,符合等保2.0三级要求与数据安全法规定。

When to Activate

  • 开发企业级AI Agent应用
  • 对接敏感内部数据的AI系统
  • 实现代码执行能力的AI助手
  • 合规审计要求的AI系统建设
  • AI安全风险评估与加固

AI Agent 安全风险矩阵

风险类型 危害等级 典型场景
Prompt注入攻击 高危 诱导Agent执行恶意指令、绕过安全限制
敏感信息泄露 高危 Agent输出内部数据、密钥、用户隐私
恶意代码执行 极高危 Agent生成并执行恶意代码,控制服务器
数据投毒 中危 污染训练数据/知识库,导致Agent输出错误信息
越权访问 高危 Agent绕过权限控制,访问未授权资源
合规风险 中危 违反数据安全法、个人信息保护法等法规

四层安全防护架构

1. 输入层防护

Prompt注入检测
from typing import List
import re

class PromptInjectionDetector:
    def __init__(self):
        self.risk_patterns = [
            # 指令绕过模式
            r"(ignore|disregard|forget).*(previous|above|prior).*(instructions|prompt|rules)",
            r"(you are|act as|pretend to be).*(not|no longer).*(assistant|AI|bot)",
            r"(override|bypass|disable).*(security|safety|content).*(filters|policies|restrictions)",
            # 系统指令模式
            r"```system\s*",
            r"<\|system\|>",
            r"SYSTEM:",
            # 诱导输出模式
            r"(output|print|reveal|disclose).*(prompt|instructions|rules|system)",
            r"(show|tell|list).*(all|full|entire).*(prompt|context|memory)"
        ]
        self.suspicious_keywords = ["jailbreak", "DAN", "dev mode", "developer mode", "unrestricted"]
    
    def detect(self, prompt: str, threshold: float = 0.7) -> dict:
        risk_score = 0.0
        matched_patterns = []
        
        # 正则匹配检测
        for pattern in self.risk_patterns:
            if re.search(pattern, prompt, re.IGNORECASE):
                risk_score += 0.2
                matched_patterns.append(pattern)
        
        # 关键词检测
        for keyword in self.suspicious_keywords:
            if keyword.lower() in prompt.lower():
                risk_score += 0.15
        
        # 特殊字符检测
        special_char_ratio = len(re.findall(r'[^\w\s,.,。?!;:""''()()、]', prompt)) / len(prompt) if prompt else 0
        if special_char_ratio > 0.3:
            risk_score += 0.25
        
        return {
            "is_risk": risk_score >= threshold,
            "risk_score": risk_score,
            "matched_patterns": matched_patterns
        }

# 使用示例
detector = PromptInjectionDetector()
result = detector.detect(user_input)
if result["is_risk"]:
    raise SecurityError("疑似Prompt注入攻击,请求已拦截")

Read the full file on GitHub · 400 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 400 lines · 39 tokens per session scan A 0050c5902fdc

Subscribe to this mod's changes

ai-agent-security is a skill published in the GitHub repository ProgrammerAnthony/Expert-Coding-Harness (235 stars, last pushed 3mo ago), licensed MIT. It adds 39 tokens to every session and 3,450 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 2 findings (makes network calls, runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.