# LeadPilot — Security Threat Model

**Document Version:** 1.0.0 (Phase 23)  
**Status:** Certified & Hardened

---

## 1. Assets & Trust Boundaries

| Asset | Criticality | Threats | Mitigations |
|---|---|---|---|
| **Lead & Contact Data** | **High** | Cross-tenant data leakage, IDOR, scraping | `TenantScope` global scope, `where('workspace_id', ...)` explicit checks, API key scoping |
| **API Keys & Secrets** | **Critical** | Key theft, replay, unauthorized access | SHA-256 token hashing, masked display (`lp_live_...last4`), scope validation |
| **Email Delivery Transport** | **High** | Email flooding, header injection, spam relaying | CRLF stripping, RFC 5322 validation, idempotency hashing, bounded retries |
| **Inbound Webhook Endpoints** | **High** | Forgery, replay attacks, DoS | HMAC-SHA256 signatures, `provider_event_id` replay protection, 5MB body limits |
| **Outbound Webhooks** | **High** | Server-Side Request Forgery (SSRF) | `SsrfProtectionService` blocking private subnets (RFC 1918), loopback, cloud metadata |
| **AI Intelligence Engine** | **Medium** | Prompt injection, credential leakage | Strict prompt boundary framing, structured output validation, heuristic fallback |

---

## 2. Threat Actor Profiles

- **Unauthenticated External Attacker:** Probes for public endpoint vulnerabilities, SQL injection, XSS, and SSRF.
- **Authenticated Malicious Workspace Member:** Attempts privilege escalation (Member to Owner), IDOR across workspaces, and mass exports.
- **Compromised Integration / Bot:** Sends flooded webhook payloads, replayed delivery events, or malicious CSV uploads.
