Security and Compliance
Overview
Read .forge/architecture.md and .forge/contracts/ to produce .forge/security.md — a comprehensive security and compliance assessment. The output must identify every data store, every trust boundary, and every regulatory requirement before any code is written.
When to Use
.forge/architecture.md exists and the system handles user data
- Regulatory requirements apply (GDPR, CCPA, SOC 2, HIPAA, PCI-DSS)
- System has multi-tenant data or PII
- Pre-launch security gate or investor due diligence
When NOT to Use
- No architecture exists — run
architecture-and-contracts first
- Looking for code-level vulnerabilities — use
code-review-and-quality security axis
- Emergency security incident — that's incident response, not planning
Common Rationalizations
| Thought |
Reality |
| "We'll handle security after MVP" |
Security retrofits cost 10x. Design it in now |
| "We don't have PII" |
Email addresses are PII. User IDs linked to behavior are PII. Audit first |
| "Our cloud provider handles compliance" |
Shared responsibility model — your provider secures infra, you secure data and access |
| "SOC 2 is only for enterprise sales" |
Any B2B buyer with a security team will ask. Start the roadmap early |
| "Encryption at rest is enough" |
Encryption without key management is theater. Who holds the keys? |
Red Flags
- No data classification scheme (what's sensitive vs. public)
- Multi-tenant system with no Row-Level Security or tenant isolation plan
- PII inventory is empty ("we don't store PII" without audit)
- Vendor list has no security assessment
- Threat model is missing or covers fewer than 5 attack vectors
- "We'll encrypt everything" without specifying what, how, and who manages keys
Core Process
Step 1: Authentication model
Define: identity provider, session management, token format, expiry policy, MFA requirements, credential storage. Map auth flow for every user type in the PRD.
Step 2: Data isolation
For multi-tenant systems: tenant isolation strategy (separate DBs, shared DB with RLS, schema-per-tenant). For single-tenant: user-level access controls. Document: how is tenant A prevented from seeing tenant B's data?
Step 3: PII inventory
Audit every data store. For each:
- What PII is stored (name, email, phone, address, payment, behavioral)
- Retention policy (how long, deletion trigger)
- Access controls (who can read, who can write)
- Encryption status (at rest, in transit)
Step 4: Regulatory scan
Based on the PII inventory and target market:
- Which regulations apply (GDPR, CCPA, HIPAA, PCI-DSS, SOC 2)?
- What consent mechanisms are required?
- What data subject rights must be supported (access, deletion, portability)?
- What breach notification requirements exist?
Step 5: Encryption audit
For each data flow and store:
- In transit: TLS version, certificate management
- At rest: encryption algorithm, key management (who holds keys, rotation policy)
- Application-level: field-level encryption for highly sensitive data
Step 6: Vendor assessment
Every third-party service or API:
- What data do they receive?
- What is their security posture (SOC 2, ISO 27001, BAA)?
- What happens to data if the vendor is breached?
- Is there a DPA (Data Processing Agreement)?
Step 7: Certification roadmap
Based on regulatory scan and sales requirements:
- Which certifications to pursue and in what order
- Timeline and estimated cost
- Gaps between current posture and certification requirements
Step 8: STRIDE threat model
For each trust boundary in the architecture:
- Spoofing: can an attacker impersonate a user or service?
- Tampering: can data be modified in transit or at rest?
- Repudiation: can actions be denied without audit trail?
- Information disclosure: can unauthorized parties access sensitive data?
- Denial of service: can the system be overwhelmed?
- Elevation of privilege: can a user gain unauthorized access?
Prioritize by likelihood × impact. Top 5 threats get specific mitigations.
Output
Write .forge/security.md with all sections above.
After writing: "Security assessment written to .forge/security.md."
Verification
1---2name: security-and-compliance3description: Evaluate security posture and regulatory compliance for a system architecture. Produces .forge/security.md with auth model, data isolation, PII inventory, regulatory requirements, encryption audit, vendor assessment, certification roadmap, and STRIDE threat model. Use when user mentions "security review", "compliance", "SOC 2", "GDPR", "PII", "threat model", or the system handles sensitive data.4---5
6# Security and Compliance
7
8## Overview
9
10Read `.forge/architecture.md` and `.forge/contracts/` to produce `.forge/security.md` — a comprehensive security and compliance assessment. The output must identify every data store, every trust boundary, and every regulatory requirement before any code is written.
11
12## When to Use
13
14- `.forge/architecture.md` exists and the system handles user data
15- Regulatory requirements apply (GDPR, CCPA, SOC 2, HIPAA, PCI-DSS)
16- System has multi-tenant data or PII
17- Pre-launch security gate or investor due diligence
18
19## When NOT to Use
20
21- No architecture exists — run `architecture-and-contracts` first
22- Looking for code-level vulnerabilities — use `code-review-and-quality` security axis
23- Emergency security incident — that's incident response, not planning
24
25## Common Rationalizations
26
27| Thought | Reality |
28|---------|---------|
29| "We'll handle security after MVP" | Security retrofits cost 10x. Design it in now |
30| "We don't have PII" | Email addresses are PII. User IDs linked to behavior are PII. Audit first |
31| "Our cloud provider handles compliance" | Shared responsibility model — your provider secures infra, you secure data and access |
32| "SOC 2 is only for enterprise sales" | Any B2B buyer with a security team will ask. Start the roadmap early |
33| "Encryption at rest is enough" | Encryption without key management is theater. Who holds the keys? |
34
35## Red Flags
36
37- No data classification scheme (what's sensitive vs. public)
38- Multi-tenant system with no Row-Level Security or tenant isolation plan
39- PII inventory is empty ("we don't store PII" without audit)
40- Vendor list has no security assessment
41- Threat model is missing or covers fewer than 5 attack vectors
42- "We'll encrypt everything" without specifying what, how, and who manages keys
43
44## Core Process
45
46### Step 1: Authentication model
47
48Define: identity provider, session management, token format, expiry policy, MFA requirements, credential storage. Map auth flow for every user type in the PRD.
49
50### Step 2: Data isolation
51
52For multi-tenant systems: tenant isolation strategy (separate DBs, shared DB with RLS, schema-per-tenant). For single-tenant: user-level access controls. Document: how is tenant A prevented from seeing tenant B's data?
53
54### Step 3: PII inventory
55
56Audit every data store. For each:
57- What PII is stored (name, email, phone, address, payment, behavioral)
58- Retention policy (how long, deletion trigger)
59- Access controls (who can read, who can write)
60- Encryption status (at rest, in transit)
61
62### Step 4: Regulatory scan
63
64Based on the PII inventory and target market:
65- Which regulations apply (GDPR, CCPA, HIPAA, PCI-DSS, SOC 2)?
66- What consent mechanisms are required?
67- What data subject rights must be supported (access, deletion, portability)?
68- What breach notification requirements exist?
69
70### Step 5: Encryption audit
71
72For each data flow and store:
73- In transit: TLS version, certificate management
74- At rest: encryption algorithm, key management (who holds keys, rotation policy)
75- Application-level: field-level encryption for highly sensitive data
76
77### Step 6: Vendor assessment
78
79Every third-party service or API:
80- What data do they receive?
81- What is their security posture (SOC 2, ISO 27001, BAA)?
82- What happens to data if the vendor is breached?
83- Is there a DPA (Data Processing Agreement)?
84
85### Step 7: Certification roadmap
86
87Based on regulatory scan and sales requirements:
88- Which certifications to pursue and in what order
89- Timeline and estimated cost
90- Gaps between current posture and certification requirements
91
92### Step 8: STRIDE threat model
93
94For each trust boundary in the architecture:
95- **S**poofing: can an attacker impersonate a user or service?
96- **T**ampering: can data be modified in transit or at rest?
97- **R**epudiation: can actions be denied without audit trail?
98- **I**nformation disclosure: can unauthorized parties access sensitive data?
99- **D**enial of service: can the system be overwhelmed?
100- **E**levation of privilege: can a user gain unauthorized access?
101
102Prioritize by likelihood × impact. Top 5 threats get specific mitigations.
103
104## Output
105
106Write `.forge/security.md` with all sections above.
107
108After writing: "Security assessment written to `.forge/security.md`."
109
110## Verification
111
112- [ ] `.forge/architecture.md` read before starting
113- [ ] Every data store has a retention policy
114- [ ] PII inventory covers all user-facing data
115- [ ] Every third-party vendor assessed
116- [ ] STRIDE threat model covers at least 5 attack vectors with mitigations
117- [ ] Certification roadmap has specific timelines
118- [ ] Multi-tenant isolation strategy is explicit (if applicable)
119- [ ] `.forge/security.md` written