|
| 1 | +# Security Plan — SecureNotes (Phase 1) |
| 2 | + |
| 3 | +**Author:** [Your Full Name] |
| 4 | +**Repo:** [https://github.com/YourGitHubUser/secure-notes](https://github.com/YourGitHubUser/secure-notes) |
| 5 | +**Date:** YYYY-MM-DD |
| 6 | + |
| 7 | +## 1. Summary |
| 8 | + |
| 9 | +This plan defines security objectives, assets, roles, high-level controls, and next steps for Phase 1 of SecureNotes (FastAPI). |
| 10 | + |
| 11 | +## 2. Security Objectives (CIA + Privacy) |
| 12 | + |
| 13 | +* **Confidentiality**: Encrypt note bodies at rest using AES-GCM with a 256-bit application master key. |
| 14 | +* **Integrity**: Use JWT with HMAC (HS256) and short token lifetimes; authenticated encryption for stored data. |
| 15 | +* **Availability**: Basic rate limiting plan and graceful error handling (to be implemented). |
| 16 | +* **Privacy**: Minimize PII; store username and password hash only; redact sensitive logs. |
| 17 | + |
| 18 | +## 3. System Assets |
| 19 | + |
| 20 | +| Asset | Classification | Comments | |
| 21 | +| -------------------------- | ---------------: | -------------------------------------- | |
| 22 | +| Note content | Sensitive | Must be encrypted at rest | |
| 23 | +| User credentials | Highly sensitive | Store hashed (bcrypt) only | |
| 24 | +| MASTER_KEY / JWT_SECRET | Secret | Store in GitHub Secrets/secret manager | |
| 25 | +| Database backups | Sensitive | Encrypt & restrict access | |
| 26 | +| CI tokens & registry creds | Secret | Least privilege in CI | |
| 27 | + |
| 28 | +## 4. Users & Roles |
| 29 | + |
| 30 | +* **User**: create/read own notes. |
| 31 | +* **Admin** (future): manage users and system. |
| 32 | +* **Developer/CI**: builds and tests; must not leak secrets. |
| 33 | + |
| 34 | +## 5. Data Flows (high level) |
| 35 | + |
| 36 | +* User → HTTPS → FastAPI endpoints (register, login, /notes) |
| 37 | +* FastAPI → encrypt note → DB (store ciphertext) |
| 38 | +* CI (GitHub Actions) → build/test/scan → images/reports |
| 39 | + |
| 40 | +A Level-0 DFD diagram is included: `docs/system_overview.png` / `.pdf`. |
| 41 | + |
| 42 | +## 6. Initial Controls to implement (Phase 2/3 plan) |
| 43 | + |
| 44 | +1. Password hashing (bcrypt via passlib). |
| 45 | +2. JWT auth (short lived access tokens). |
| 46 | +3. AES-GCM encryption for note bodies (app master key from secrets). |
| 47 | +4. Pydantic input validation for all endpoints. |
| 48 | +5. Security headers middleware (CSP, HSTS, X-Frame-Options). |
| 49 | +6. CI: CodeQL, Snyk (SCA), Trivy (container), OWASP ZAP (DAST). |
| 50 | + |
| 51 | +## 7. Key risks & mitigations |
| 52 | + |
| 53 | +* **Leak of master key** → use GitHub Secrets & rotation plan. |
| 54 | +* **Dependency vulnerabilities** → Snyk scans and upgrades. |
| 55 | +* **Misconfigured CI secrets** → restrict access & do not echo secrets in logs. |
| 56 | + |
| 57 | +## 8. Phase-1 acceptance criteria |
| 58 | + |
| 59 | +* Repo forked and branch `phase1-setup` created. |
| 60 | +* Security Plan and DFD added to `docs/`. |
| 61 | +* PR created (and merged). |
0 commit comments