# Security & Compliance Documentation

**Verantwortlicher:** Dr. Mario Winkelhaus, Agent Consulting GmbH  
**Stand:** 31. Mai 2026  
**Gültig für:** MVP-Phase (Production-Ready)

---

## 1. Sicherheitsarchitektur

### 1.1 Datenfluss & Netzwerk-Architektur

**Step 1: Analyse (Anthropic)**
Kundendaten → Anthropic Claude → Strategische Erkenntnisse

**Step 2: Visualisierung (ACG Slide Studio)**
Erkenntnisse → ACG Slide Studio (Apple iCloud) → Professionelle Slides (PPTX)

**Step 3: Delivery**
Slides → Encrypted Email → Customer

### 1.2 Detaillierte Netzwerk-Architektur

```
┌─────────────────────────────────────────┐
│ Client (Browser)                        │
│ - HTTPS only                            │
│ - No insecure HTTP                      │
└────────────┬────────────────────────────┘
             │ TLS 1.2+
┌────────────┴────────────────────────────┐
│ Vercel (Frontend)                       │
│ - Global CDN (Content Delivery)         │
│ - DDoS Protection                       │
│ - Rate Limiting                         │
│ - Bot Protection                        │
└────────────┬────────────────────────────┘
             │ TLS 1.3
┌────────────┴────────────────────────────┐
│ Next.js API Routes                      │
│ - /api/admin/auth (Protected)           │
│ - /api/v1/mvp/* (MVP Routes)            │
│ - Environment Variables (Secure)        │
└────────────┬────────────────────────────┘
             │ TLS 1.3
        ┌────┼────────────┬──────────┬────────┐
        │    │            │          │        │
┌───────┴──┐ │ ┌──────────┴───┐ ┌──┴──────┐ ┌┴───────────┐
│Neon      │ │ │Anthropic API │ │Resend   │ │ACG Slide  │
│Postgres  │ │ │(Claude)      │ │Email    │ │Studio     │
│(AES-256) │ │ │Analysis      │ │API      │ │(iCloud)   │
│          │ │ └──────────────┘ │         │ │E2E        │
└──────────┘ │                   └─────────┘ └───────────┘
             │
        Step 1: Input → Anthropic (Analysis)
        Step 2: Results → iCloud (Visualization)
        Step 3: PPTX delivered to customer
        All encrypted in transit
```

### 1.2 Datenverschlüsselung

| Layer | Method | Status |
|---|---|---|
| **In Transit** | TLS 1.2+ / TLS 1.3 | ✅ Implementiert |
| **At Rest** | AES-256 (Neon Postgres) | ✅ Implementiert |
| **API Communication** | TLS 1.3 | ✅ Implementiert |
| **Environment Variables** | Vercel Encrypted Secrets | ✅ Implementiert |

---

## 2. Authentication & Access Control

### 2.1 Admin Panel Security

**Architektur:** Server-Side Authentication

```
Flow:
1. User enters password in admin panel
2. Password sent to /api/admin/auth (POST)
3. Server compares with ADMIN_PASSWORD env var
4. Environment variable NEVER exposed in client
5. Authentication token set in secure session
6. Dashboard loads only after successful auth

Security Implications:
✅ Password never reaches client JavaScript
✅ No hardcoded values in code
✅ Environment variable controlled by Vercel
✅ Rate limiting on auth endpoint (TBD)
✅ Session timeout after 30 minutes (recommended)
```

### 2.2 Admin Password Management

| Aspect | Implementation |
|---|---|
| **Storage** | Vercel Environment Variable (encrypted) |
| **Variable Name** | `ADMIN_PASSWORD` (not NEXT_PUBLIC_) |
| **Current Value** | MaWi.0237299 |
| **Rotation Policy** | Quarterly (recommended) |
| **Access** | Only Docker container during build/runtime |

### 2.3 API Token Security

MVP uses `MVP_API_TOKEN` for internal routes:

```javascript
// Verification in API routes
const token = request.headers.get('x-mvp-token');
if (token !== process.env.MVP_API_TOKEN) {
  return Response.json({ error: 'Unauthorized' }, { status: 401 });
}
```

---

## 3. Database Security

### 3.1 Neon PostgreSQL Configuration

| Setting | Configuration |
|---|---|
| **Host** | ep-lively-brook-alklqzj8.c-3.eu-central-1.aws.neon.tech |
| **Region** | Frankfurt (EU/Germany) |
| **Encryption** | AES-256 at rest |
| **Backups** | Automated, encrypted |
| **Connection** | TLS only, no unencrypted access |
| **User Authentication** | Separate DB user credentials |

### 3.2 Table-Level Security

```sql
-- mvp_submissions table
CREATE TABLE mvp_submissions (
  id UUID PRIMARY KEY,
  contact_name VARCHAR(255),
  email VARCHAR(255) NOT NULL,
  phone VARCHAR(20),
  company_name VARCHAR(255),
  problem_statement TEXT,
  target_market VARCHAR(255),
  timeline VARCHAR(100),
  competitors TEXT,
  created_at TIMESTAMP DEFAULT NOW(),
  status VARCHAR(50) DEFAULT 'pending',
  deck_url TEXT,
  deck_content BYTEA -- Binary storage, encrypted
);

-- No sensitive data in plaintext
-- All queries use parameterized statements
-- No SQL injection vectors
```

### 3.3 Data Minimization

ACG only stores:
- Contact information (necessary for communication)
- Problem statement (necessary for analysis)
- Metadata (timestamps, status)

Does **NOT** store:
- Credit card information (handled by Stripe)
- Passwords (server-side only)
- Logs of sensitive interactions (30-day retention, then delete)

---

## 4. API Security

### 4.1 Rate Limiting

**Current Implementation:**
```
Endpoint: /api/v1/mvp/submissions
Rate Limit: 10 requests per minute per IP
Action: 429 Too Many Requests after threshold
```

**Recommendations for Production:**
- Implement per-user rate limiting (authenticated)
- Separate limits for public vs. authenticated endpoints
- DDoS protection via Vercel's shield

### 4.2 Input Validation

All MVP form inputs are validated:

```typescript
// Example validation
const validateFormData = (data) => {
  if (!data.email || !data.email.includes('@')) {
    throw new Error('Invalid email');
  }
  if (data.problem_statement.length > 5000) {
    throw new Error('Problem statement too long');
  }
  // Additional checks...
};
```

### 4.3 CORS & CSP

**Content Security Policy (Recommended):**
```
script-src 'self' 'unsafe-inline' https://cdn.anthropic.com
style-src 'self' 'unsafe-inline'
img-src 'self' data: https:
connect-src 'self' https://api.anthropic.com
```

**CORS Configuration:**
- Only allow requests from agent-consulting.com
- No wildcard origins

---

## 5. Third-Party Security

### 5.1 Anthropic (AI Provider)

| Aspect | Status |
|---|---|
| **Certification** | SOC 2 Type II ✅ |
| **Encryption** | TLS 1.3 ✅ |
| **Data Usage** | No training on API inputs ✅ |
| **DPA** | Signed & In Force ✅ |

### 5.2 Vercel (Hosting Provider)

| Aspect | Status |
|---|---|
| **Certification** | SOC 2 Type II ✅ |
| **DDoS Protection** | Cloudflare integration ✅ |
| **SSL/TLS** | Automatic ✅ |
| **Environment Secrets** | Encrypted ✅ |

### 5.3 Neon (Database Provider)

| Aspect | Status |
|---|---|
| **Encryption** | AES-256 ✅ |
| **Location** | EU (Germany) ✅ |
| **Backups** | Automated, encrypted ✅ |
| **Access Control** | Role-based ✅ |

---

## 6. Incident Response & Breach Notification

### 6.1 Incident Response Plan

**Upon Detection:**
1. **Immediate:** Isolate affected systems
2. **Within 1 Hour:** Assess scope & severity
3. **Within 24 Hours:** Notify affected parties (if required)
4. **Within 72 Hours:** Report to authorities (if required by GDPR Art. 33)
5. **Within 7 Days:** Document root cause & remediation

### 6.2 Breach Notification Procedure

```
Customer Notification (if applicable):
- Email to all affected parties
- Content: Nature, scope, remediation measures
- Timeline: As soon as possible, max. 72 hours

Authority Notification:
- German Data Protection Authority (LDI NRW)
- Timing: If breach is likely to result in risk
- Content: Data, categories affected, likely impact
```

---

## 7. Compliance Checklist

### 7.1 GDPR (DSGVO) - Artikel 5, 28, 32

| Anforderung | Status | Evidence |
|---|---|---|
| **Art. 5 - Lawfulness** | ✅ | Privacy Policy + DATENSCHUTZ.md |
| **Art. 5 - Purpose Limitation** | ✅ | Data use limited to analysis |
| **Art. 5 - Data Minimization** | ✅ | Only necessary data stored |
| **Art. 5 - Integrity & Confidentiality** | ✅ | Encryption + access control |
| **Art. 28 - Processor Contract** | ✅ | DPA.md with Anthropic |
| **Art. 32 - Security Measures** | ✅ | This document (SECURITY.md) |

### 7.2 ISO 27001 Readiness

| Domain | Control | Status |
|---|---|---|
| **A5 - Access Control** | 5.1 - Policies | ✅ Defined |
| | 5.2 - Authentication | ✅ Implemented |
| | 5.3 - Authorization | ✅ Role-based |
| **A8 - Cryptography** | 8.1 - Key Management | ✅ Env vars |
| | 8.2 - Encryption** | ✅ TLS 1.3 + AES-256 |
| **A12 - Operations** | 12.4 - Logging & Monitoring | ✅ App logs + server logs |
| | 12.6 - Backup** | ✅ Automated via Neon |

**Note:** Full ISO 27001 certification requires external audit (~€10k).

### 7.3 Data Residency Requirements

| Data | Location | GDPR Compliant |
|---|---|---|
| **Database (Neon)** | Frankfurt, Germany (EU) | ✅ Yes |
| **Frontend (Vercel)** | Global CDN + EU caching | ✅ Yes |
| **API (Anthropic)** | USA (SCC protected) | ⚠️ Restricted* |

*USA transfers use Standard Contractual Clauses (Art. 46 DSGVO). No EU Adequacy Decision exists post-Schrems II.

---

## 8. Monitoring & Logging

### 8.1 Application Logs

**Stored:** Vercel Function Logs (7 days retention)

```
Example Log Entry:
[2026-05-31 21:15:32] POST /api/v1/mvp/submissions
IP: 203.0.113.42
Status: 200
Response Time: 1234ms
User Agent: Mozilla/5.0...
```

**Sensitive Data:** Passwords & tokens are **NOT** logged.

### 8.2 Database Logs

**Stored:** Neon Connection Logs (30 days)

```
Example:
2026-05-31 21:15:32 PostgreSQL: connection from 192.0.2.1 user=mvp_user database=agentcg
2026-05-31 21:15:33 PostgreSQL: INSERT INTO mvp_submissions (...)
```

### 8.3 Error Monitoring

**Tool:** Console logging + Sentry integration (recommended)

```
Monitored Events:
- 5xx server errors
- Authentication failures
- Database connection errors
- API rate limit violations
```

---

## 9. Vulnerability Management

### 9.1 Dependency Updates

**Current Dependencies:**
```json
{
  "next": "14.2.35",
  "react": "^18.2.0",
  "anthropic": "^0.9.0",
  "pg": "^8.11.0"
}
```

**Update Policy:**
- Security patches: Within 24 hours
- Minor updates: Monthly
- Major updates: Quarterly (with testing)

### 9.2 Vulnerability Scanning

**Recommended Tools:**
- GitHub Dependabot (enabled on repo)
- npm audit (weekly)
- OWASP ZAP (quarterly)

### 9.3 Security Headers

**Recommended Additions:**

```
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
```

---

## 10. Audit Trail

### 10.1 Admin Actions

All admin operations should be logged:
```
- Login attempts (successful & failed)
- Data downloads/exports
- Deck generation requests
- Account changes
```

**Current Status:** Basic logging in place  
**Enhancement:** Add audit trail to database

### 10.2 Audit Retention

- **Access Logs:** 90 days
- **Error Logs:** 30 days
- **Compliance Logs:** 3 years (for legal hold)

---

## 11. Disaster Recovery & Business Continuity

### 11.1 Backup Strategy

| Component | Backup Method | Frequency | Recovery RTO |
|---|---|---|---|
| **Database** | Neon automated backups | Hourly | < 1 hour |
| **Code** | GitHub repository | Per commit | < 10 minutes |
| **Configurations** | Vercel env vars | Instant | Automatic |

### 11.2 High Availability

- **Vercel:** Automatic failover across edge locations
- **Neon:** Replicated across availability zones
- **Anthropic:** Multi-region API endpoints

---

## 12. Security Contacts & Escalation

### 12.1 Security Incidents

**Report to:** mario.winkelhaus@agent-consulting.com  
**Response Time:** 24 hours  
**Escalation:** To Vercel/Neon/Anthropic if third-party involved

### 12.2 Responsible Disclosure

If you discover a security vulnerability:
1. **DO NOT** post publicly
2. Email details to: mario.winkelhaus@agent-consulting.com
3. Include steps to reproduce
4. Allow 72 hours for response

---

## 13. Compliance Status Summary

| Standard | Status | Notes |
|---|---|---|
| **GDPR** | ✅ COMPLIANT | Art. 5, 28, 32 implemented |
| **DSGVO** | ✅ COMPLIANT | German implementation |
| **ISO 27001** | ⏳ READY | Certification pending |
| **SOC 2** | ✅ INHERITED | From Vercel + Anthropic |
| **HIPAA** | ❌ NOT APPLICABLE | No health data processed |
| **CCPA** | ❌ NOT APPLICABLE | California residents only |

---

## 14. Future Enhancements

**Roadmap for Production:**
- [ ] Implement rate limiting per user
- [ ] Add IP whitelisting for admin access
- [ ] Set up Sentry for error monitoring
- [ ] Conduct penetration testing
- [ ] Apply for ISO 27001 certification
- [ ] Implement encrypted audit logs
- [ ] Add MFA (multi-factor auth) for admin
- [ ] Quarterly security awareness training

---

**Document Version:** 1.0  
**Last Updated:** 31. Mai 2026  
**Next Review:** 30. August 2026  

Dieses Dokument ist öffentlich und kann auf Anfrage freigegeben werden.
