00-andruia-consultant
Usar al iniciar o mejorar un proyecto de IA: diagnostica código y restricciones, propone skills existentes y redacta tareas y un…
Secure AI agents against prompt injection, tool abuse, and data exfiltration
Claude Code
$ npx -y skills add sickn33/agentic-awesome-skills --skill ai-agent-security --agent claude-code
Codex
$ npx skills add sickn33/agentic-awesome-skills --skill ai-agent-security -a codex -y
Cursor
$ npx skills add sickn33/agentic-awesome-skills --skill ai-agent-security -a cursor -y
Gemini CLI
$ npx skills add sickn33/agentic-awesome-skills --skill ai-agent-security -a gemini-cli -y
GitHub Copilot
$ npx skills add sickn33/agentic-awesome-skills --skill ai-agent-security -a github-copilot -y
OpenCode
$ npx skills add sickn33/agentic-awesome-skills --skill ai-agent-security -a opencode -y
Windsurf
$ npx skills add sickn33/agentic-awesome-skills --skill ai-agent-security -a windsurf -y
name: ai-agent-security description: Secure AI agents against prompt injection, tool abuse, and data exfiltration with defense-in-depth controls. category: security risk: safe source: https://github.com/BagelHole/DevOps-Security-Agent-Skills source_repo: BagelHole/DevOps-Security-Agent-Skills source_type: community date_added: '2026-09-20' license: MIT license_source: https://github.com/BagelHole/DevOps-Security-Agent-Skills/blob/main/LICENSE compatibility: Requires the relevant security tooling (scanners, vault CLIs) and an authorized scope for any active assessment. Docs-only; helper scripts and templates not bundled. metadata: author: devops-skills version: '2.0'
Protect agentic AI systems from adversarial input, unsafe tool execution, data leakage, and privilege abuse with layered security controls.
These are partial design sketches, not a working security boundary. Regexes/classifiers have false positives and false negatives; prompt text cannot grant permissions. Enforce tenant identity, resource scope and approved actions in the tool service using authenticated server-side context. Input signing authenticates origin, not the safety of signed content. Bind approvals to the exact operation/arguments and recheck immediately before execution. Test failure paths and concurrency before production use.
AI agents introduce a unique threat surface. Apply STRIDE specifically to agentic components:
| Threat | Agent-Specific Example | Control | |--------|----------------------|---------| | **Spoofing** | Attacker crafts input that mimics a trusted internal tool response | Signed tool responses, HMAC verification | | **Tampering** | Prompt injection modifies agent reasoning mid-chain | Input validation, prompt armoring | | **Repudiation** | Agent takes destructive action with no audit trail | Immutable structured logging | | **Information Disclosure** | Agent leaks PII, secrets, or internal architecture in responses | Output filtering, content classifiers | | **Denial of Service** | Adversarial prompt causes infinite tool loops or token exhaustion | Rate limits, token budgets, circuit breakers | | **Elevation of Privilege** | Agent escalates from read-only to write via chained tool calls | RBAC per tool, least-privilege scoping |
**Prompt Injection** — Untrusted content (user input, web scrapes, document contents) manipulates the agent's system prompt or reasoning chain to execute unintended actions.
**Tool Abuse** — The agent calls tools in sequences or with parameters the designer did not anticipate, achieving effects beyond its intended scope.
**Data Exfiltration** — The agent encodes sensitive data (credentials, PII, internal IPs) into its responses, tool calls, or outbound HTTP requests.
**Cross-Tenant Leakage** — In multi-tenant deployments, context from one tenant's session bleeds into another through shared memory, vector stores, or cache.
**Privilege Escalation** — The agent chains low-privilege tool calls to achieve high-privilege outcomes (e.g., read config -> extract credentials -> call admin API).
Every input to an agent must be sanitized before it reaches the model or any tool. This includes user messages, tool outputs being fed back, and retrieved documents.
import re
from dataclasses import dataclass
from enum import Enum
class RiskLevel(Enum):
LOW = "low"
MEDIUM = "medium"
HIGH = "high"
CRITICAL = "critical"
@dataclass
class ValidationResult:
is_safe: bool
risk_level: RiskLevel
matched_rules: list[str]
sanitized_input: str
INJECTION_PATTERNS = [
(r"ignore\s+(all\s+)?(previous|prior|above)\s+(instructions|prompts|rules)", "instruction_override"),
(r"you\s+are\s+now\s+(a|an|the)\s+", "role_hijack"),
(r"system\s*:\s*", "system_prompt_inject"),
(r"<\|?(system|im_start|endoftext)\|?>", "control_token_inject"),
(r"\[INST\]|\[\/INST\]|<<SYS>>", "template_inject"),
(r"(?:execute|run|eval)\s*\(", "code_execution_attempt"),
(r"(?:curl|wget|nc|ncat)\s+", "network_command_inject"),
(r"(?:rm\s+-rf|mkfs|dd\s+if=|chmod\s+777)", "destructive_command"),
(r"(?:\/etc\/passwd|\/etc\/shadow|\.env\b|\.ssh\/)", "path_traversal"),
(r"(?:BEGIN\s+(?:RSA|DSA|EC)\s+PRIVATE\s+KEY)", "secret_exfil_attempt"),
]
def validate_agent_input(user_input: str, max_length: int = 4096) -> ValidationResult:
"""Validate and sanitize input before passing to agent."""
matched = []
risk = RiskLevel.LOW
# Length check
if len(user_input) > max_length:
matched.append("input_too_long")
risk = RiskLevel.MEDIUM
# Null byte and control character removal
sanitized = user_input.replace("\x00", "")
sanitized = re.sub(r"[\x01-\x08\x0b\x0c\x0e-\x1f]", "", sanitized)
# Pattern matching
for pattern, rule_name in INJECTION_PATTERNS:
if re.search(pattern, sanitized, re.IGNORECASE):
matched.append(rule_name)
risk = RiskLevel.HIGH
# Stacked injection detection (multiple suspicious patterns)
if len(matched) >= 3:
risk = RiskLevel.CRITICAL
is_safe = not matched # heuristic result only; never authorization
return ValidationResult(
is_safe=is_safe,
risk_level=risk,
matched_rules=matched,
sanitized_input=sanitized[:max_length] if is_safe else "",
)Use a lightweight classifier as middleware before the agent processes any input:
from functools import wraps from typing import Callable def input_guard(valida
Find reusable instructions for your project, inspect their complete files, and keep an exact skill set you can review and reuse.
Usar al iniciar o mejorar un proyecto de IA: diagnostica código y restricciones, propone skills existentes y redacta tareas y un…
Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and…
Usar para crear o mejorar una skill de Andru.ia: define entradas y resultados, redacta SKILL.md con ejemplos y límites, valida la…
Usar tras definir el sector de un proyecto: prepara un dossier en español con contexto, normas aplicables, patrones UX y riesgos,…
AI-powered presentation generation via the 2slides API — create slides from text, match a reference image style, summarize…
360 feedback register: reviewer, subject, review cycle, visibility, due date and score, as CSV, SQL, JSON Schema or Notion on…
Use your assigned AgentMail inbox to read email tasks, explicitly send or reply, and check delivery. Provided automatically by…
Create a new Architecture Decision Record with sequential numbering and AgentDB registration