Llm Security Redteaming
Skill Profile
(Select at least one profile to enable specific modules)
Overview
LLM security encompasses protecting AI systems from prompt injection, jailbreaks, data leakage, and adversarial attacks. Red teaming proactively identifies vulnerabilities before malicious actors exploit them.
Why This Matters
- Data protection: Prevent sensitive data leakage
- System integrity: Maintain intended behavior
- Compliance: Meet security requirements
- Trust: Users rely on safe AI systems
Core Concepts & Rules
1. Core Principles
- Follow established patterns and conventions
- Maintain consistency across codebase
- Document decisions and trade-offs
2. Implementation Guidelines
- Start with the simplest viable solution
- Iterate based on feedback and requirements
- Test thoroughly before deployment
Inputs / Outputs / Contracts
- Inputs:
- User prompts and inputs
- LLM responses
- Context and retrieved documents
- Security policies and rules
- Entry Conditions:
- LLM application deployed
- Security policies defined
- Guardrails configured
- Monitoring enabled
- Outputs:
- Sanitized inputs
- Filtered outputs
- Security alerts
- Red team reports
- Artifacts Required (Deliverables):
- Guardrails configuration
- Security monitoring dashboard
- Red team test reports
- Incident response documentation
- Acceptance Evidence:
- Prompt injection blocked
- Jailbreak attempts detected
- PII redacted from outputs
- Security alerts triggered
- Success Criteria:
- Prompt injection detection rate > 95%
- Jailbreak detection rate > 95%
- PII redaction rate 100%
- Zero security incidents
Skill Composition
Quick Start / Implementation Example
- Review requirements and constraints
- Set up development environment
- Implement core functionality following patterns
- Write tests for critical paths
- Run tests and fix issues
- Document any deviations or decisions
# Example implementation following best practices
def example_function():
# Your implementation here
pass
Assumptions / Constraints / Non-goals
- Assumptions:
- Development environment is properly configured
- Required dependencies are available
- Team has basic understanding of domain
- Constraints:
- Must follow existing codebase conventions
- Time and resource limitations
- Compatibility requirements
- Non-goals:
- This skill does not cover edge cases outside scope
- Not a replacement for formal training
Compatibility & Prerequisites
- Supported Versions:
- Python 3.8+
- Node.js 16+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Required AI Tools:
- Code editor (VS Code recommended)
- Testing framework appropriate for language
- Version control (Git)
- Dependencies:
- Language-specific package manager
- Build tools
- Testing libraries
- Environment Setup:
.env.example keys: API_KEY, DATABASE_URL (no values)
Test Scenario Matrix (QA Strategy)
| Type |
Focus Area |
Required Scenarios / Mocks |
| Unit |
Core Logic |
Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
| Integration |
DB / API |
All external API calls or database connections must be mocked during unit tests |
| E2E |
User Journey |
Critical user flows to test |
| Performance |
Latency / Load |
Benchmark requirements |
| Security |
Vuln / Auth |
SAST/DAST or dependency audit |
| Frontend |
UX / A11y |
Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives & Error Recovery
(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)
- Thinking Process: Analyze root cause before fixing. Do not brute-force.
- Fallback Strategy: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
- Self-Review: Check against Guardrails & Anti-patterns before finalizing.
- Output Constraints: Output ONLY the modified code block. Do not explain unless asked.
Definition of Done (DoD) Checklist
Anti-patterns / Pitfalls
- ⛔ Don't: Log PII, catch-all exception, N+1 queries
- ⚠️ Watch out for: Common symptoms and quick fixes
- 💡 Instead: Use proper error handling, pagination, and logging
Reference Links & Examples
- Internal documentation and examples
- Official documentation and best practices
- Community resources and discussions
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
1---2name: llm-security-redteaming3description: LLM security encompasses protecting AI systems from prompt injection, jailbreaks, data leakage, and adversarial attacks. Red teaming proactively identifies vulnerabilities before malicious actors expl4---5
6# Llm Security Redteaming
7
8## Skill Profile
9*(Select at least one profile to enable specific modules)*
10- [ ] **DevOps**
11- [x] **Backend**
12- [ ] **Frontend**
13- [ ] **AI-RAG**
14- [ ] **Security Critical**
15
16## Overview
17LLM security encompasses protecting AI systems from prompt injection, jailbreaks, data leakage, and adversarial attacks. Red teaming proactively identifies vulnerabilities before malicious actors exploit them.
18
19## Why This Matters
20- **Data protection**: Prevent sensitive data leakage
21- **System integrity**: Maintain intended behavior
22- **Compliance**: Meet security requirements
23- **Trust**: Users rely on safe AI systems
24
25---
26
27## Core Concepts & Rules
28
29### 1. Core Principles
30- Follow established patterns and conventions
31- Maintain consistency across codebase
32- Document decisions and trade-offs
33
34### 2. Implementation Guidelines
35- Start with the simplest viable solution
36- Iterate based on feedback and requirements
37- Test thoroughly before deployment
38
39
40## Inputs / Outputs / Contracts
41* **Inputs**:
42 - User prompts and inputs
43 - LLM responses
44 - Context and retrieved documents
45 - Security policies and rules
46* **Entry Conditions**:
47 - LLM application deployed
48 - Security policies defined
49 - Guardrails configured
50 - Monitoring enabled
51* **Outputs**:
52 - Sanitized inputs
53 - Filtered outputs
54 - Security alerts
55 - Red team reports
56* **Artifacts Required (Deliverables)**:
57 - Guardrails configuration
58 - Security monitoring dashboard
59 - Red team test reports
60 - Incident response documentation
61* **Acceptance Evidence**:
62 - Prompt injection blocked
63 - Jailbreak attempts detected
64 - PII redacted from outputs
65 - Security alerts triggered
66* **Success Criteria**:
67 - Prompt injection detection rate > 95%
68 - Jailbreak detection rate > 95%
69 - PII redaction rate 100%
70 - Zero security incidents
71
72## Skill Composition
73* **Depends on**: [skill-model-serving-inference](./model-serving-inference/), [skill-prompting-patterns](./prompting-patterns/)
74* **Compatible with**: [skill-retrieval-quality](./retrieval-quality/), [skill-ai-governance](../../44-ai-governance/)
75* **Conflicts with**: None
76* **Related Skills**: [skill-security-baseline](../../64-meta-standards/security-baseline-controls/), [skill-data-classification](../../46-data-classification/)
77
78---
79
80## Quick Start / Implementation Example
81
821. Review requirements and constraints
832. Set up development environment
843. Implement core functionality following patterns
854. Write tests for critical paths
865. Run tests and fix issues
876. Document any deviations or decisions
88
89```python
90# Example implementation following best practices
91def example_function():
92 # Your implementation here
93 pass
94```
95
96
97## Assumptions / Constraints / Non-goals
98
99* **Assumptions**:
100 - Development environment is properly configured
101 - Required dependencies are available
102 - Team has basic understanding of domain
103* **Constraints**:
104 - Must follow existing codebase conventions
105 - Time and resource limitations
106 - Compatibility requirements
107* **Non-goals**:
108 - This skill does not cover edge cases outside scope
109 - Not a replacement for formal training
110
111
112## Compatibility & Prerequisites
113
114* **Supported Versions**:
115 - Python 3.8+
116 - Node.js 16+
117 - Modern browsers (Chrome, Firefox, Safari, Edge)
118* **Required AI Tools**:
119 - Code editor (VS Code recommended)
120 - Testing framework appropriate for language
121 - Version control (Git)
122* **Dependencies**:
123 - Language-specific package manager
124 - Build tools
125 - Testing libraries
126* **Environment Setup**:
127 - `.env.example` keys: `API_KEY`, `DATABASE_URL` (no values)
128
129
130## Test Scenario Matrix (QA Strategy)
131
132| Type | Focus Area | Required Scenarios / Mocks |
133| :--- | :--- | :--- |
134| **Unit** | Core Logic | Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
135| **Integration** | DB / API | All external API calls or database connections must be mocked during unit tests |
136| **E2E** | User Journey | Critical user flows to test |
137| **Performance** | Latency / Load | Benchmark requirements |
138| **Security** | Vuln / Auth | SAST/DAST or dependency audit |
139| **Frontend** | UX / A11y | Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
140
141
142## Technical Guardrails & Security Threat Model
143
144### 1. Security & Privacy (Threat Model)
145* **Top Threats**: Injection attacks, authentication bypass, data exposure
146- [ ] **Data Handling**: Sanitize all user inputs to prevent Injection attacks. Never log raw PII
147- [ ] **Secrets Management**: No hardcoded API keys. Use Env Vars/Secrets Manager
148- [ ] **Authorization**: Validate user permissions before state changes
149
150### 2. Performance & Resources
151- [ ] **Execution Efficiency**: Consider time complexity for algorithms
152- [ ] **Memory Management**: Use streams/pagination for large data
153- [ ] **Resource Cleanup**: Close DB connections/file handlers in finally blocks
154
155### 3. Architecture & Scalability
156- [ ] **Design Pattern**: Follow SOLID principles, use Dependency Injection
157- [ ] **Modularity**: Decouple logic from UI/Frameworks
158
159### 4. Observability & Reliability
160- [ ] **Logging Standards**: Structured JSON, include trace IDs `request_id`
161- [ ] **Metrics**: Track `error_rate`, `latency`, `queue_depth`
162- [ ] **Error Handling**: Standardized error codes, no bare except
163- [ ] **Observability Artifacts**:
164 - **Log Fields**: timestamp, level, message, request_id
165 - **Metrics**: request_count, error_count, response_time
166 - **Dashboards/Alerts**: High Error Rate > 5%
167
168
169## Agent Directives & Error Recovery
170*(ข้อกำหนดสำหรับ AI Agent ในการคิดและแก้ปัญหาเมื่อเกิดข้อผิดพลาด)*
171
172- **Thinking Process**: Analyze root cause before fixing. Do not brute-force.
173- **Fallback Strategy**: Stop after 3 failed test attempts. Output root cause and ask for human intervention/clarification.
174- **Self-Review**: Check against Guardrails & Anti-patterns before finalizing.
175- **Output Constraints**: Output ONLY the modified code block. Do not explain unless asked.
176
177
178## Definition of Done (DoD) Checklist
179
180- [ ] Tests passed + coverage met
181- [ ] Lint/Typecheck passed
182- [ ] Logging/Metrics/Trace implemented
183- [ ] Security checks passed
184- [ ] Documentation/Changelog updated
185- [ ] Accessibility/Performance requirements met (if frontend)
186
187
188## Anti-patterns / Pitfalls
189
190* ⛔ **Don't**: Log PII, catch-all exception, N+1 queries
191* ⚠️ **Watch out for**: Common symptoms and quick fixes
192* 💡 **Instead**: Use proper error handling, pagination, and logging
193
194
195## Reference Links & Examples
196
197* Internal documentation and examples
198* Official documentation and best practices
199* Community resources and discussions
200
201
202## Versioning & Changelog
203
204* **Version**: 1.0.0
205* **Changelog**:
206 - 2026-02-22: Initial version with complete template structure