Enterprise

AI Rules for SOC 2 Compliance

SOC 2 audits evaluate trust service criteria: security, availability, processing integrity, confidentiality, and privacy. AI rules must encode these criteria into every feature so that AI-generated code passes SOC 2 audits by default.

7 min read·July 5, 2025

SOC 2 auditors examine every feature. AI rules that encode trust service criteria produce audit-ready code by default.

Security controls, availability patterns, processing integrity, data classification, and evidence generation

SOC 2: What the Auditor Looks For

SOC 2 (System and Organization Controls 2) is the most common compliance framework for SaaS companies. It evaluates five Trust Service Criteria (TSC): Security (the foundation — required for every SOC 2 audit), Availability (system uptime and performance), Processing Integrity (data processing is complete, valid, accurate, and timely), Confidentiality (data classified as confidential is protected), and Privacy (personal information is collected, used, retained, and disclosed appropriately).

SOC 2 Type I: evaluates control design at a point in time. SOC 2 Type II: evaluates control design AND operating effectiveness over a period (typically 6-12 months). Most customers and enterprise buyers require Type II. AI rule: 'SOC 2 controls must be continuously operational, not just designed. The AI must generate code that produces evidence of control operation (logs, metrics, audit trails) — not just code that implements the control.'

Why AI rules matter for SOC 2: every feature the AI generates is subject to audit. If the AI generates an API endpoint without authentication: that is a security control gap. If it generates a data pipeline without logging: that is an audit trail gap. If it generates infrastructure without encryption: that is a confidentiality gap. The AI rules encode SOC 2 requirements so that generated code is audit-ready by default.

Security: The Required Trust Service Criterion

Security (CC — Common Criteria) is required for every SOC 2 audit. Key controls: CC6.1 (logical and physical access controls), CC6.2 (authentication mechanisms), CC6.3 (access authorization based on roles), CC6.6 (protection against threats — firewalls, IDS, vulnerability management), CC7.1 (monitoring for anomalies), CC7.2 (incident detection and response), CC8.1 (change management).

AI rules for CC6 (Access Controls): 'Every API endpoint: authenticated (CC6.2) and authorized by role (CC6.3). No public endpoints that access user data. Session management: secure tokens, expiration, revocation. MFA: required for admin accounts and sensitive operations. The AI must never generate an endpoint that bypasses authentication or returns data without authorization checks.'

AI rules for CC7 (Monitoring): 'Every application: structured logging for security events. Authentication attempts (success and failure), authorization decisions, data access, configuration changes, and error conditions. Logs forwarded to SIEM. Alerts configured for: repeated authentication failures, privilege escalation attempts, unusual data access patterns. The AI must generate security event logging alongside every security-relevant feature.'

AI rules for CC8 (Change Management): 'Code changes: version-controlled, peer-reviewed, tested, and deployed through a CI/CD pipeline. No direct production changes. The AI should generate: migration scripts (not manual database changes), feature flags (not direct code toggles), and deployment configurations (not manual server updates). Every change produces a reviewable artifact.'

⚠️ No Public Endpoints That Access User Data

SOC 2 CC6.1 requires logical access controls. An API endpoint that returns user data without authentication is a control failure the auditor will flag immediately. This includes: unauthenticated GraphQL introspection that reveals schema, public health check endpoints that leak internal state, and debug endpoints left in production. The AI must generate authentication middleware on every endpoint that touches user or system data.

Availability and Processing Integrity

Availability (A1): the system meets its service level agreements. Controls: A1.1 (capacity planning), A1.2 (disaster recovery and backup). AI rules: 'Generate health check endpoints (/health, /ready) for monitoring. Generate database backup configurations. Generate auto-scaling rules based on load metrics. Generate circuit breakers for external dependencies (when a dependency is down, degrade gracefully, do not cascade the failure).'

Processing Integrity (PI1): data processing is complete, valid, accurate, and timely. Controls: PI1.1 (input validation), PI1.2 (processing completeness checks), PI1.3 (output accuracy verification). AI rules: 'Every data input: validated at the boundary (type, format, range, business rules). Every batch process: reconciliation check (input count = output count, no records lost). Every calculation: verified against expected ranges. Generate validation functions at every system boundary — API inputs, file uploads, webhook payloads, queue messages.'

The practical pattern: for every data pipeline the AI generates, include a reconciliation step. Records in = records out (plus any expected transforms). If the counts do not match: alert and pause the pipeline. For every API endpoint: input validation that rejects malformed data before processing. These patterns satisfy PI controls and prevent data corruption.

💡 Reconciliation Catches Silent Data Loss

A batch job processes 10,000 records but silently drops 3 due to a parsing error. Without reconciliation: those 3 records are gone. With reconciliation: input count (10,000) does not match output count (9,997) → alert fires → investigation finds the parsing bug. AI-generated data pipelines should always count records at input and output, comparing the counts as the final step. This simple pattern satisfies SOC 2 PI1.2 (processing completeness).

Confidentiality and Privacy

Confidentiality (C1): data classified as confidential is protected throughout its lifecycle. Controls: C1.1 (data classification), C1.2 (disposal of confidential data). AI rules: 'Classify every data field: public, internal, confidential, restricted. Confidential data: encrypted at rest (AES-256), encrypted in transit (TLS 1.2+), access-logged, and securely disposed of when no longer needed. The AI must generate encryption for all confidential fields and secure deletion routines (overwrite, not just delete).'

Privacy (P1-P8): personal information handling complies with the entity's privacy commitments. Controls cover: notice (P1), choice and consent (P2), collection (P3), use and retention (P4), access (P5), disclosure (P6), quality (P7), and monitoring (P8). AI rules: 'Personal data collection: only what is disclosed in the privacy policy. Consent: recorded before collection. Retention: automated deletion after the retention period. Access: users can view and export their data. Deletion: users can request deletion (honor within 30 days). The AI must generate data lifecycle management alongside data collection features.'

Evidence generation: SOC 2 Type II requires evidence that controls operated effectively over the audit period. AI rule: 'Every control must produce evidence: access reviews (quarterly reports of who has access to what), encryption status (automated verification that encryption is enabled on all data stores), change management records (PR reviews, deployment logs), and incident response records (how security events were detected and resolved). The AI should generate the evidence collection mechanism alongside the control itself.'

ℹ️ Evidence Is What the Auditor Actually Reviews

A SOC 2 auditor does not read your source code. They review evidence: access review reports (who has access, was it reviewed quarterly), change management records (were PRs reviewed, were tests run), encryption verification (is encryption enabled on all data stores), and incident response records (was the alert investigated, what was the resolution). The AI should generate the evidence collection mechanism (quarterly access reports, deployment audit logs) alongside the control implementation.

SOC 2 AI Rules Summary

Summary of AI rules that map to SOC 2 Trust Service Criteria for audit-ready code generation.

  • Security (required): authentication on all endpoints, role-based authorization, MFA for admins
  • Monitoring: structured security event logs, SIEM forwarding, anomaly alerts
  • Change management: version control, peer review, CI/CD pipeline, no direct production changes
  • Availability: health checks, backups, auto-scaling, circuit breakers for dependencies
  • Processing integrity: input validation, reconciliation checks, output verification
  • Confidentiality: data classification, encryption at rest and in transit, secure disposal
  • Privacy: consent before collection, retention limits, user access/export/deletion rights
  • Evidence: every control produces audit evidence. Type II requires continuous operation proof