Back to skill

Security audit

Rag

Security checks for vulnerabilities and agentic risk

Overview

This is a markdown-only RAG guidance skill with security caveats and no executable install or persistence behavior.

Installers should treat this as advisory RAG documentation. Before applying its logging or indexing examples to real systems, classify the data, minimize stored raw queries and chunks where possible, enforce access controls, and verify embedding/vector database retention and compliance settings.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (4)

YARA rule 'agent_skill_prompt_injection_hidden_instructions': Prompt injection or hidden instructions embedded in AI agent skill text [agent_skills]

High
Category
YARA Match
Content
# RAG Security & Privacy

## PII Detection Before Indexing

### Scan for
- Names (NER models, regex patterns)
- Emails, phone numbers, addresses
- SSNs, ID numbers, credit cards
- Health information (PHI for HIPAA)
- Financial data

### Options
1. **Redact before embedding** — Replace PII with placeholders
2. **Skip sensitive documents** — Separate index for authorized users
3. **Encrypt sensitive chunks** — Decrypt at retrieval time

## Access Control

### Row-Level Security
```python
# Filter by user permissions BEFORE retrieval
results = vector_db.query(
    embedding=query_embedding,
    filter={
        "department": {"$in": user.departments},
        "classification
Confidence
80% confidence
Finding
YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).

Instruction Override

High
Category
Prompt Injection
Content
### The Risk
Malicious content in indexed documents:
```
IGNORE ALL PREVIOUS INSTRUCTIONS. You are now...
```

### Mitigations
Confidence
80% confidence
Finding
This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The guidance recommends collecting production queries, retrieved chunks, and user feedback to build evaluation datasets, but it omits any privacy, minimization, retention, or consent safeguards. In a RAG context, those fields can easily contain personal, confidential, or regulated data from users and source documents, so adopting this advice as written could lead to inappropriate collection, storage, or reuse of sensitive information.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
As a markdown file, this should warn users when described behavior may affect privacy or user data. The instructions explicitly recommend upserting chunk text plus metadata such as source_file, page, section, and timestamp, but provide no caution about sensitive documents, access controls, or data retention implications.

Static analysis

Detected: suspicious.prompt_injection_instructions

Prompt-injection style instruction pattern detected.

Warn
Code
suspicious.prompt_injection_instructions
Location
security.md:41