Back to Docs
TECHNICAL GUIDE
AI Security Playbook - Technical Implementation
Implementation details for securing AI systems against the 10 critical threat categories. Code examples, compliance mappings, and testing procedures.
Overview
This technical guide provides implementation details for the HAIEC AI Security Playbook. Use these code examples and patterns to implement deterministic controls for AI attack surface management.
For the full playbook with executive brief
Visit the AI Security Playbook marketing page to download the complete PDF with executive brief and tactical guide.
Threat Categories - Implementation
1. Prompt Injection & Indirect Injection
CriticalMalicious inputs overriding system instructions
Compliance Mapping
OWASP LLM01SOC 2 CC7.2NIST AI RMF
Implementation Example
# Input validation with structured intent schema
from pydantic import BaseModel, validator
class UserPrompt(BaseModel):
intent: str
parameters: dict
@validator('intent')
def validate_intent(cls, v):
allowed_intents = ['search', 'summarize', 'translate']
if v not in allowed_intents:
raise ValueError(f'Intent must be one of {allowed_intents}')
return v2. Jailbreaks & Safety Bypass
HighCircumventing safety guardrails
Compliance Mapping
OWASP LLM01ISO 42001 8.5
Implementation Example
# Multi-layer safety checks
class SafetyGuardrail:
def __init__(self):
self.blocked_patterns = [
r'ignore.*instructions',
r'bypass.*safety',
r'pretend.*you.*are',
]
def check_input(self, text: str) -> bool:
for pattern in self.blocked_patterns:
if re.search(pattern, text, re.IGNORECASE):
return False
return True3. RAG Poisoning & Corpus Contamination
HighInjecting malicious content into retrieval data
Compliance Mapping
SOC 2 CC6.1ISO 27001 A.12.6.1
Implementation Example
# Corpus signing and verification
import hashlib
class CorpusSigner:
def __init__(self, secret_key: str):
self.secret_key = secret_key
def sign_document(self, doc: str) -> dict:
signature = hashlib.sha256(
f"{doc}{self.secret_key}".encode()
).hexdigest()
return {"content": doc, "signature": signature}4. Tool & Function-Call Abuse
HighExploiting API access capabilities
Compliance Mapping
NIST AI RMF MANAGE-1.1SOC 2 CC6.6
Implementation Example
# Least-privilege function calling
class FunctionRegistry:
def __init__(self):
self.functions = {}
self.permissions = {}
def register(self, name: str, func: callable, role: str):
self.functions[name] = func
self.permissions[name] = role
def call(self, name: str, user_role: str, **kwargs):
if user_role != self.permissions[name]:
raise PermissionError(f"Role {user_role} cannot call {name}")
return self.functions[name](**kwargs)Framework Alignment
NIST AI RMF 1.0
- GOVERN-1.1
- MAP-1.5
- MEASURE-2.3
- MANAGE-1.1
ISO 42001:2023
- 6.1 Risk Assessment
- 7.4 Documentation
- 8.5 Testing
- 8.7 Oversight
OWASP LLM Top 10
- LLM01 Prompt Injection
- LLM03 Training Poisoning
- LLM07 Insecure Plugin
Colorado AI Act
- Affirmative Defense
- Impact Assessments
- Consumer Notices
Testing & Validation
CLI Commands
# Run full adversarial test suite haiec scan --type ai-security --path ./my-ai-app # Test specific threat category haiec scan --type ai-security --rules R1,R2,R6 --path ./src # Generate compliance report haiec scan --type ai-security --output json --compliance soc2