Petru Constantin is the founder of DeviDevs and designed the multi-agent platform the company runs on, with guardrails enforced in code. Code examples are written against the EU AI Act (Regulation (EU) 2024/1689) with the Digital Omnibus on AI timeline as of 15 November 2026, Python 3.12+ documentation.
Building an Enterprise AI Security Framework: A Strategic Approach
As an organization runs more AI systems, ad-hoc security measures stop scaling: each team ends up with its own rules and nobody sees the overall risk. An enterprise AI security framework gives the structure to manage AI risk the same way across the organization.
This guide presents a framework for building enterprise-grade AI security programs.
Framework Overview
An effective enterprise AI security framework consists of five interconnected domains:
┌─────────────────────┐
│ AI Governance │
│ & Accountability │
└─────────┬───────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Risk Management │ │ Technical │ │ Operational │
│ & Assessment │ │ Security │ │ Security │
│ │ │ Controls │ │ │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │
└────────────────────┼────────────────────┘
│
┌─────────▼───────────┐
│ Compliance & │
│ Audit │
└─────────────────────┘
Domain 1: AI Governance & Accountability
Governance Structure
from dataclasses import dataclass
from datetime import datetime, timezone
from typing import List, Optional
from enum import Enum
# Skeleton: methods prefixed with _ that are not shown (_load_policies,
# _check_*) are integration points with your AI inventory and approval workflow.
class AIRiskLevel(Enum):
LOW = "low"
MEDIUM = "medium"
HIGH = "high"
CRITICAL = "critical"
@dataclass
class AIGovernanceStructure:
"""Enterprise AI governance organizational structure."""
# Board Level
board_ai_committee: bool = True
board_reporting_frequency: str = "quarterly"
# Executive Level
chief_ai_officer: bool = True
ai_ethics_officer: bool = True
ai_security_lead: bool = True
# Operational Level
ai_review_board: dict = None
ai_security_team: dict = None
business_unit_ai_leads: List[str] = None
def __post_init__(self):
if self.ai_review_board is None:
self.ai_review_board = {
'members': [
'Chief AI Officer',
'AI Ethics Officer',
'AI Security Lead',
'Legal Counsel',
'Privacy Officer',
'Business Unit Representatives'
],
'meeting_frequency': 'monthly',
'responsibilities': [
'Review high-risk AI deployments',
'Approve AI security policies',
'Oversee AI incident response',
'Monitor AI risk posture'
]
}
@dataclass
class AIPolicy:
"""Enterprise AI security policy."""
policy_id: str
title: str
version: str
effective_date: str
owner: str
scope: str
requirements: List[dict]
exceptions_process: str
review_frequency: str = "annual"
class AIGovernanceFramework:
"""Manage enterprise AI governance."""
def __init__(self, config: dict):
self.structure = AIGovernanceStructure(**config.get('structure', {}))
self.policies = self._load_policies(config.get('policies', []))
self.risk_appetite = config.get('risk_appetite', {})
def assess_deployment_governance(self, ai_system: dict) -> dict:
"""Assess if AI deployment meets governance requirements."""
assessment = {
'system_id': ai_system['id'],
'assessment_date': datetime.now(timezone.utc).isoformat(),
'checks': []
}
# Check 1: Policy compliance
policy_check = self._check_policy_compliance(ai_system)
assessment['checks'].append(policy_check)
# Check 2: Risk level within appetite
risk_check = self._check_risk_appetite(ai_system)
assessment['checks'].append(risk_check)
# Check 3: Required approvals obtained
approval_check = self._check_approvals(ai_system)
assessment['checks'].append(approval_check)
# Check 4: Documentation complete
doc_check = self._check_documentation(ai_system)
assessment['checks'].append(doc_check)
# Overall assessment
assessment['compliant'] = all(c['passed'] for c in assessment['checks'])
assessment['required_actions'] = [
c['remediation'] for c in assessment['checks']
if not c['passed'] and c.get('remediation')
]
return assessmentAI Ethics and Responsible Use
class AIEthicsFramework:
"""Framework for ethical AI development and deployment."""
principles = {
'fairness': {
'description': 'AI systems should treat all individuals fairly',
'requirements': [
'Bias assessment before deployment',
'Regular fairness audits',
'Diverse training data',
'Explainable decision processes'
]
},
'transparency': {
'description': 'AI systems should be transparent about their nature and limitations',
'requirements': [
'Clear AI disclosure to users',
'Documented decision logic',
'Accessible explanations for affected parties',
'Published AI governance policies'
]
},
'accountability': {
'description': 'Clear accountability for AI system outcomes',
'requirements': [
'Designated system owners',
'Defined escalation paths',
'Incident response procedures',
'Regular governance reviews'
]
},
'privacy': {
'description': 'AI systems should protect individual privacy',
'requirements': [
'Privacy impact assessments',
'Data minimization',
'Purpose limitation',
'User consent where required'
]
},
'safety': {
'description': 'AI systems should be safe and secure',
'requirements': [
'Security testing before deployment',
'Continuous monitoring',
'Fail-safe mechanisms',
'Regular security updates'
]
}
}
def assess_ethical_compliance(self, ai_system: dict) -> dict:
"""Assess AI system against ethics framework."""
assessment = {
'system_id': ai_system['id'],
'principles_assessment': {}
}
for principle, details in self.principles.items():
principle_assessment = {
'compliant': True,
'requirements_met': [],
'requirements_not_met': []
}
for requirement in details['requirements']:
is_met = self._check_requirement(ai_system, principle, requirement)
if is_met:
principle_assessment['requirements_met'].append(requirement)
else:
principle_assessment['requirements_not_met'].append(requirement)
principle_assessment['compliant'] = False
assessment['principles_assessment'][principle] = principle_assessment
assessment['overall_compliant'] = all(
p['compliant'] for p in assessment['principles_assessment'].values()
)
return assessmentDomain 2: Risk Management & Assessment
AI Risk Assessment Framework
import uuid
from datetime import datetime, timezone
from typing import List
# Skeleton: _assess_factor, _generate_recommendations, _determine_treatment and
# _calculate_residual_risk are where your own scoring rules go; they are not shown.
class AIRiskAssessment:
"""Comprehensive AI risk assessment framework."""
risk_categories = {
'security': {
'weight': 0.25,
'factors': [
'prompt_injection_vulnerability',
'data_poisoning_risk',
'model_theft_exposure',
'adversarial_robustness',
'access_control_strength'
]
},
'privacy': {
'weight': 0.20,
'factors': [
'training_data_pii',
'inference_data_sensitivity',
'data_retention_practices',
'cross_border_transfers',
'anonymization_effectiveness'
]
},
'operational': {
'weight': 0.20,
'factors': [
'availability_criticality',
'scalability_risk',
'dependency_concentration',
'disaster_recovery_readiness',
'monitoring_capability'
]
},
'reputational': {
'weight': 0.15,
'factors': [
'bias_potential',
'output_harm_possibility',
'transparency_level',
'public_perception_sensitivity',
'media_exposure_risk'
]
},
'compliance': {
'weight': 0.20,
'factors': [
'regulatory_applicability',
'documentation_completeness',
'audit_readiness',
'consent_management',
'rights_request_capability'
]
}
}
def assess_risk(self, ai_system: dict) -> dict:
"""Perform comprehensive risk assessment."""
assessment = {
'assessment_id': str(uuid.uuid4()),
'system_id': ai_system['id'],
'assessment_date': datetime.now(timezone.utc).isoformat(),
'assessor': ai_system.get('assessor'),
'category_scores': {},
'overall_risk_score': 0,
'risk_level': None,
'findings': [],
'recommendations': []
}
total_weighted_score = 0
for category, details in self.risk_categories.items():
category_score = self._assess_category(ai_system, category, details['factors'])
assessment['category_scores'][category] = category_score
total_weighted_score += category_score['score'] * details['weight']
# Collect findings
for finding in category_score.get('findings', []):
assessment['findings'].append({
'category': category,
**finding
})
assessment['overall_risk_score'] = round(total_weighted_score, 2)
assessment['risk_level'] = self._determine_risk_level(assessment['overall_risk_score'])
assessment['recommendations'] = self._generate_recommendations(assessment)
return assessment
def _determine_risk_level(self, score: float) -> str:
"""Determine risk level from score."""
if score >= 80:
return 'critical'
elif score >= 60:
return 'high'
elif score >= 40:
return 'medium'
else:
return 'low'
def _assess_category(self, ai_system: dict, category: str,
factors: List[str]) -> dict:
"""Assess a specific risk category."""
factor_scores = []
findings = []
for factor in factors:
score, finding = self._assess_factor(ai_system, factor)
factor_scores.append(score)
if finding:
findings.append(finding)
return {
'score': sum(factor_scores) / len(factor_scores),
'factor_scores': dict(zip(factors, factor_scores)),
'findings': findings
}
class AIRiskTreatment:
"""AI risk treatment planning and tracking."""
treatment_options = {
'mitigate': {
'description': 'Implement controls to reduce risk',
'examples': [
'Add input validation',
'Implement access controls',
'Deploy monitoring',
'Add guardrails'
]
},
'transfer': {
'description': 'Transfer risk to third party',
'examples': [
'Cyber insurance',
'Vendor liability agreements',
'Indemnification clauses'
]
},
'accept': {
'description': 'Accept residual risk with approval',
'examples': [
'Document risk acceptance',
'Obtain executive sign-off',
'Implement monitoring'
]
},
'avoid': {
'description': 'Eliminate the risk by not proceeding',
'examples': [
'Do not deploy the system',
'Remove risky features',
'Choose alternative approach'
]
}
}
def create_treatment_plan(self, risk_assessment: dict) -> dict:
"""Create risk treatment plan based on assessment."""
treatment_plan = {
'assessment_id': risk_assessment['assessment_id'],
'created_date': datetime.now(timezone.utc).isoformat(),
'treatments': [],
'residual_risk': None
}
for finding in risk_assessment['findings']:
treatment = self._determine_treatment(finding)
treatment_plan['treatments'].append(treatment)
# Calculate expected residual risk
treatment_plan['residual_risk'] = self._calculate_residual_risk(
risk_assessment['overall_risk_score'],
treatment_plan['treatments']
)
return treatment_planDomain 3: Technical Security Controls
Layered Security Architecture
class AISecurityControlsFramework:
"""Technical security controls for AI systems."""
control_layers = {
'perimeter': {
'controls': [
{
'id': 'PER-001',
'name': 'API Gateway Protection',
'description': 'All AI API traffic routed through secured gateway',
'implementation': 'WAF, rate limiting, authentication'
},
{
'id': 'PER-002',
'name': 'Network Segmentation',
'description': 'AI infrastructure isolated in dedicated network segment',
'implementation': 'VLANs, firewall rules, micro-segmentation'
},
{
'id': 'PER-003',
'name': 'DDoS Protection',
'description': 'Protection against volumetric attacks',
'implementation': 'Cloud DDoS protection, rate limiting'
}
]
},
'application': {
'controls': [
{
'id': 'APP-001',
'name': 'Input Validation',
'description': 'All inputs validated and sanitized',
'implementation': 'Schema validation, injection detection'
},
{
'id': 'APP-002',
'name': 'Output Filtering',
'description': 'AI outputs filtered for harmful content',
'implementation': 'Content policy, PII detection, output validators'
},
{
'id': 'APP-003',
'name': 'Guardrails',
'description': 'Behavioral guardrails on AI systems',
'implementation': 'Prompt engineering, fine-tuning, runtime checks'
}
]
},
'data': {
'controls': [
{
'id': 'DAT-001',
'name': 'Encryption at Rest',
'description': 'All AI data encrypted at rest',
'implementation': 'AES-256, key management'
},
{
'id': 'DAT-002',
'name': 'Encryption in Transit',
'description': 'All data encrypted in transit',
'implementation': 'TLS 1.3, certificate pinning'
},
{
'id': 'DAT-003',
'name': 'Data Classification',
'description': 'AI training and inference data classified',
'implementation': 'Data labeling, handling policies'
}
]
},
'identity': {
'controls': [
{
'id': 'IDN-001',
'name': 'Authentication',
'description': 'Strong authentication for AI access',
'implementation': 'OAuth2, API keys, MFA'
},
{
'id': 'IDN-002',
'name': 'Authorization',
'description': 'Fine-grained access control',
'implementation': 'RBAC, attribute-based access'
},
{
'id': 'IDN-003',
'name': 'Service Identity',
'description': 'Strong identity for AI services',
'implementation': 'Service accounts, workload identity'
}
]
},
'monitoring': {
'controls': [
{
'id': 'MON-001',
'name': 'Security Logging',
'description': 'Comprehensive security event logging',
'implementation': 'SIEM integration, audit trails'
},
{
'id': 'MON-002',
'name': 'Anomaly Detection',
'description': 'Detect anomalous AI behavior',
'implementation': 'ML-based detection, threshold alerting'
},
{
'id': 'MON-003',
'name': 'Model Monitoring',
'description': 'Monitor model performance and drift',
'implementation': 'Performance metrics, drift detection'
}
]
}
}
def assess_control_coverage(self, ai_system: dict) -> dict:
"""Assess security control coverage for AI system."""
assessment = {
'system_id': ai_system['id'],
'layers': {},
'overall_coverage': 0,
'gaps': []
}
total_controls = 0
implemented_controls = 0
for layer, details in self.control_layers.items():
layer_assessment = {
'controls': [],
'coverage': 0
}
for control in details['controls']:
status = self._check_control_implementation(ai_system, control)
layer_assessment['controls'].append({
**control,
'status': status
})
total_controls += 1
if status == 'implemented':
implemented_controls += 1
elif status == 'partial':
implemented_controls += 0.5
else:
assessment['gaps'].append({
'layer': layer,
'control': control['id'],
'name': control['name'],
'priority': self._get_control_priority(control)
})
layer_implemented = sum(
1 if c['status'] == 'implemented' else 0.5 if c['status'] == 'partial' else 0
for c in layer_assessment['controls']
)
layer_assessment['coverage'] = layer_implemented / len(details['controls'])
assessment['layers'][layer] = layer_assessment
assessment['overall_coverage'] = implemented_controls / total_controls
return assessmentDomain 4: Operational Security
AI Security Operations
from datetime import datetime, timezone
from typing import List
# Skeleton: AIIncidentResponse, AIVulnerabilityManagement and the _-prefixed
# helpers (_triage_alert, _collect_telemetry, ...) connect to your SIEM and
# ticketing system; they are not shown.
class AISecurityOperations:
"""Operational security for AI systems."""
def __init__(self, config: dict):
self.monitoring = AISecurityMonitoring(config.get('monitoring', {}))
self.incident_response = AIIncidentResponse(config.get('ir', {}))
self.vulnerability_management = AIVulnerabilityManagement(config.get('vuln', {}))
def run_security_operations(self):
"""Continuous security operations."""
# 1. Monitor AI systems
alerts = self.monitoring.collect_and_analyze()
for alert in alerts:
# 2. Triage alerts
triage_result = self._triage_alert(alert)
if triage_result['is_incident']:
# 3. Escalate to incident response
self.incident_response.create_incident(alert, triage_result)
elif triage_result['is_vulnerability']:
# 4. Add to vulnerability queue
self.vulnerability_management.add_finding(alert)
# 5. Generate operations report
return self._generate_ops_report()
class AISecurityMonitoring:
"""Security monitoring for AI systems."""
def __init__(self, config: dict):
self.detection_rules = self._load_detection_rules(config)
self.baselines = self._load_baselines(config)
def collect_and_analyze(self) -> List[dict]:
"""Collect telemetry and detect anomalies."""
alerts = []
# Collect telemetry from all AI systems
telemetry = self._collect_telemetry()
# Run detection rules
for rule in self.detection_rules:
matches = rule.evaluate(telemetry)
for match in matches:
alerts.append({
'rule_id': rule.id,
'severity': rule.severity,
'match_data': match,
'timestamp': datetime.now(timezone.utc).isoformat()
})
# Baseline anomaly detection
anomalies = self._detect_baseline_anomalies(telemetry)
alerts.extend(anomalies)
return alerts
# Pseudo-queries: translate them to your SIEM's query language.
# Pattern-based injection detection only catches known phrasings.
detection_rules_examples = [
{
'id': 'AI-DET-001',
'name': 'Prompt Injection Attempt',
'description': 'Detect prompt injection patterns in inputs',
'severity': 'high',
'query': '''
SELECT * FROM ai_requests
WHERE input MATCHES injection_patterns
AND timestamp > now() - interval '5 minutes'
'''
},
{
'id': 'AI-DET-002',
'name': 'Model Extraction Attempt',
'description': 'Detect systematic querying patterns',
'severity': 'critical',
'query': '''
SELECT user_id, COUNT(*) as query_count,
STDDEV(input_similarity) as pattern_score
FROM ai_requests
WHERE timestamp > now() - interval '1 hour'
GROUP BY user_id
HAVING query_count > 1000 AND pattern_score < 0.3
'''
},
{
'id': 'AI-DET-003',
'name': 'Guardrail Bypass Attempt',
'description': 'Detect attempts to bypass safety guardrails',
'severity': 'critical',
'query': '''
SELECT * FROM ai_requests
WHERE guardrail_triggered = true
AND same_user_within_5min_count > 5
'''
}
]Domain 5: Compliance & Audit
Compliance Framework
import uuid
from datetime import datetime, timezone
from typing import List
# Skeleton: _assess_regulation, _audit_area, _generate_recommendations and
# _calculate_audit_rating hold your own criteria; they are not shown.
class AIComplianceFramework:
"""Manage AI compliance requirements."""
regulatory_requirements = {
'eu_ai_act': {
'name': 'EU AI Act (Regulation (EU) 2024/1689)',
'applicable_to': 'AI systems placed on the market or used in the EU',
'key_requirements': [
'Risk classification',
'Technical documentation',
'Human oversight',
'Transparency',
'Quality management',
'Conformity assessment'
],
# Dates as amended by the Digital Omnibus on AI (AI Act Service Desk timeline);
# recheck the official timeline before relying on them
'timeline': {
'prohibited_practices': '2025-02',
'gpai_requirements': '2025-08',
'article_50_transparency': '2026-08',
'article_50_2_marking_systems_on_market_before_2026_08': '2026-12',
'new_prohibitions_sexual_deepfakes_and_csam': '2026-12',
'high_risk_annex_iii': '2027-12',
'high_risk_annex_i': '2028-08'
}
},
'gdpr': {
'name': 'General Data Protection Regulation',
'applicable_to': 'Processing of EU personal data',
'key_requirements': [
'Lawful basis for processing',
'Data minimization',
'Purpose limitation',
'Data subject rights',
'Data protection impact assessment',
'Privacy by design'
]
},
'ccpa': {
'name': 'California Consumer Privacy Act',
'applicable_to': 'California residents\' data',
'key_requirements': [
'Disclosure requirements',
'Opt-out rights',
'Access and deletion rights',
'Non-discrimination'
]
}
}
def assess_compliance(self, ai_system: dict,
regulations: List[str]) -> dict:
"""Assess AI system compliance with regulations."""
assessment = {
'system_id': ai_system['id'],
'assessment_date': datetime.now(timezone.utc).isoformat(),
'regulations': {}
}
for reg in regulations:
if reg in self.regulatory_requirements:
reg_assessment = self._assess_regulation(
ai_system,
self.regulatory_requirements[reg]
)
assessment['regulations'][reg] = reg_assessment
# Overall compliance status
assessment['overall_compliant'] = all(
r['compliant'] for r in assessment['regulations'].values()
)
return assessment
class AIAuditFramework:
"""Framework for AI system audits."""
audit_areas = {
'governance': [
'Policy documentation',
'Accountability structures',
'Risk management processes',
'Change management'
],
'technical': [
'Security controls implementation',
'Access control effectiveness',
'Monitoring and logging',
'Incident response capability'
],
'data': [
'Data governance',
'Data quality',
'Privacy controls',
'Data retention'
],
'model': [
'Model documentation',
'Model performance',
'Bias assessment',
'Explainability'
],
'operations': [
'Operational procedures',
'Training records',
'Incident history',
'Continuous improvement'
]
}
def conduct_audit(self, ai_system: dict, scope: List[str]) -> dict:
"""Conduct AI system audit."""
audit_report = {
'audit_id': str(uuid.uuid4()),
'system_id': ai_system['id'],
'audit_date': datetime.now(timezone.utc).isoformat(),
'scope': scope,
'findings': [],
'recommendations': [],
'overall_rating': None
}
for area in scope:
if area in self.audit_areas:
area_findings = self._audit_area(ai_system, area)
audit_report['findings'].extend(area_findings)
# Generate recommendations
audit_report['recommendations'] = self._generate_recommendations(
audit_report['findings']
)
# Calculate overall rating
audit_report['overall_rating'] = self._calculate_audit_rating(
audit_report['findings']
)
return audit_reportImplementation Roadmap
## AI Security Framework Implementation Roadmap
### Phase 1: Foundation (Months 1-3)
- [ ] Establish AI governance structure
- [ ] Define AI security policies
- [ ] Conduct initial AI inventory
- [ ] Perform baseline risk assessment
- [ ] Identify regulatory requirements
### Phase 2: Core Controls (Months 4-6)
- [ ] Implement perimeter security controls
- [ ] Deploy application security controls
- [ ] Establish data protection measures
- [ ] Configure identity and access management
- [ ] Set up security monitoring
### Phase 3: Operations (Months 7-9)
- [ ] Establish security operations processes
- [ ] Deploy detection capabilities
- [ ] Create incident response procedures
- [ ] Implement vulnerability management
- [ ] Train security team on AI threats
### Phase 4: Compliance (Months 10-12)
- [ ] Complete compliance assessments
- [ ] Address compliance gaps
- [ ] Prepare audit documentation
- [ ] Conduct internal audit
- [ ] Establish continuous compliance monitoring
### Phase 5: Maturity (Ongoing)
- [ ] Continuous improvement
- [ ] Regular framework updates
- [ ] Benchmarking against standards
- [ ] Advanced threat detection
- [ ] AI security innovationConclusion
Building an enterprise AI security framework requires commitment across all levels of the organization - from board-level governance to technical implementation to operational excellence. The framework presented here provides a foundation that can be adapted to your organization's specific needs and risk profile.
Key success factors:
- Executive sponsorship - AI security requires top-down commitment
- Cross-functional collaboration - Security, legal, data science, and business must work together
- Risk-based approach - Focus resources on highest-risk AI systems
- Continuous improvement - The AI threat landscape evolves rapidly
- Measurement and metrics - Track progress and demonstrate value
If you want an outside review of an AI system against these five domains, DeviDevs runs AI security audits.
From production
JARVIS, the multi-agent platform DeviDevs runs on Claude Code, is a small-scale version of the governance and technical-controls domains above. Its security rules are code, not text: in the main sessions, hooks run before every shell command, file write, web request and agent start (file reads are not covered). That design came from a failure: two agents ignored a rule that existed only in writing, so the principle became "a rule should be code, not documentation" (24 September 2026). Emails to existing clients leave only after a person approves the exact text, except for a client the founder has put on automatic support replies; a hook records the approval only when a person types the send confirmation after the draft was shown, and a pre-action rule blocks the usual ways the model could write it itself. Governance has a running cost too. The founder approves hooks and rules with arguments for and against; he rejected a hook that would have cost about 8,000 tokens; and since rules pile up and duplicate each other, they get reviewed and removed, not only added (two were removed on 15 October 2026). Between 7 September and 15 November 2026 all hook rules, security and workflow together, made about 2,200 blocks in working sessions.
Official references
- Timeline for the implementation of the EU AI Act - AI Act Service Desk
- FAQ - AI Act Service Desk
- datetime - Basic date and time types
- OWASP Top 10 for LLM Applications 2025
Related on this site: Every AI Security Startup Got Acquired. Now What?, Your AI Agent Framework Is Probably Compromised Right Now, AI API Security: Auth, Authorization & Rate Limiting. More articles in the AI Security category, and the engineering work behind them is on the services page.
Need an AI system built and running in production, with the scope agreed in writing and a delivery guarantee? See how a DeviDevs Sprint works →