Addressed SA-3 by encrypting the sqlite content with a .env secret
This commit is contained in:
+9
-6
@@ -65,13 +65,16 @@ These findings are prioritized below. Severity describes the potential security
|
||||
|
||||
### SA-003: Sensitive secrets stored in plaintext SQLite
|
||||
|
||||
**Severity:** High
|
||||
**Evidence:** `backend/app/services/email_service.py` stores SMTP settings including `smtp_password` in `app_settings`; `backend/app/services/mastodon_oauth.py` stores Mastodon application secrets and user access tokens in `app_settings` and `user_plugin_config`; `backend/app/api/user_config.py` stores `otp_secret` in the `users` table.
|
||||
**Severity:** High, remediated in current worktree for newly written secrets
|
||||
**Evidence:** `backend/app/services/email_service.py` stores SMTP settings including `smtp_password` in `app_settings`; `backend/app/services/mastodon_oauth.py` stores Mastodon application secrets and user access tokens in `app_settings` and `user_plugin_config`; `backend/app/api/user_config.py` stores `otp_secret` in the `users` table. New writes are encrypted, but legacy plaintext rows require rotation.
|
||||
**Impact:** Read access to the database exposes SMTP credentials, Mastodon posting authority, OAuth client secrets, and TOTP seeds. TOTP seeds cannot be changed by a user who loses the database copy. Database backups therefore contain reusable credentials, not just application data.
|
||||
|
||||
**Recommendation:** Encrypt secrets at rest using an external secret-management system or an application encryption key held outside the database. At minimum, use a dedicated secret key supplied through a protected environment/secret file, encrypt sensitive values before SQLite storage, restrict file and volume permissions, and document backup key management. Rotate all credentials after a suspected database disclosure. Continue omitting secrets from API responses.
|
||||
**Current state:** Newly stored SMTP passwords, Mastodon OAuth client secrets and access tokens, and TOTP seeds are encrypted with Fernet using `LINKLOG_DATA_ENCRYPTION_KEY`. The key is required in Docker and is not stored in SQLite. The user plugin API no longer returns the Mastodon access token.
|
||||
**Residual impact:** Existing plaintext secrets require a controlled read-and-save rotation after the key is configured. Lost encryption keys make stored secrets unrecoverable.
|
||||
|
||||
**Priority:** High.
|
||||
**Recommendation:** Supply `LINKLOG_DATA_ENCRYPTION_KEY` through a protected secret mechanism, encrypt backups, rotate credentials after suspected disclosure, and migrate existing plaintext values. Continue omitting secrets from API responses.
|
||||
|
||||
**Priority:** Completed for new writes; existing secret migration and key management remain.
|
||||
|
||||
### SA-004: User-controlled Mastodon instance creates SSRF and uncontrolled egress risk
|
||||
|
||||
@@ -206,7 +209,7 @@ These findings are prioritized below. Severity describes the potential security
|
||||
|
||||
## Data Protection Review
|
||||
|
||||
- SQLite is the primary data store and contains profile data, links, password hashes, tokens, SMTP settings, Mastodon credentials, OAuth state, and OTP secrets.
|
||||
- SQLite is the primary data store and contains profile data, links, password hashes, tokens, SMTP settings, Mastodon credentials, OAuth state, and OTP secrets. New sensitive values are encrypted with the externally supplied Fernet key; existing plaintext values must be rotated.
|
||||
- Database backups must be treated as credential-bearing secrets, encrypted, access-controlled, rotated, and tested for secure deletion.
|
||||
- Avatar files are persistent and publicly served. Validate and re-encode image content before accepting production uploads.
|
||||
- Link URLs and comments are intentionally public feed data. Operators should document that users must not submit secrets in URLs or comments.
|
||||
@@ -228,7 +231,7 @@ Before production exposure:
|
||||
|
||||
- [ ] Replace SHA-256 password hashing with Argon2id, scrypt, or bcrypt and migrate existing accounts.
|
||||
- [ ] Remove query-string token authentication and rotate existing access tokens.
|
||||
- [ ] Encrypt SMTP, Mastodon, OAuth, and OTP secrets at rest; protect encryption keys separately.
|
||||
- [x] Encrypt newly written SMTP, Mastodon, OAuth, and OTP secrets at rest; protect the encryption key separately. Rotate legacy plaintext values.
|
||||
- [ ] Add login, OTP, reset-mail, and setup rate limiting.
|
||||
- [ ] Restrict Mastodon instance validation and outbound network egress.
|
||||
- [ ] Disable direct host publication of the application port in production.
|
||||
|
||||
Reference in New Issue
Block a user