feat(security): warn when ActiveRecord encryption is not configured
Merged
AN
6mo ago+79+79+01234567890123456789-0-0-0123456789
Make it obvious when a self-hosted instance is storing sensitive data unencrypted at rest. No behaviour change, just added visibility.
When no explicit encryption keys are configured (ACTIVE_RECORD_ENCRYPTION_* env vars or Rails credentials), sensitive columns such as API keys, provider/bank tokens, and PII (email, names) are stored in plaintext. The app boots and works normally, so users can be unaware their data isn't encrypted.
This PR adds warnings, gated on app_mode.self_hosted? && !ActiveRecordEncryptionConfig.explicitly_configured?:
- Startup log warning (
config/initializers/encryption_warning.rb) — visible
indocker logs. - Warning banner on
/settings/security, reusing the existingDS::Alert
pattern already used for the encryption banner on/settings/providers.
Screenshot
Testing
bin/rails test test/controllers/settings/securities_controller_test.rb— green (banner shown when unconfigured, hidden when configured).bin/rubocopandbundle exec erb_lint— clean.- Verified live in a self-hosted container both ways: banner +
[SECURITY]log when unconfigured; neither when the keys are set.
Summary by CodeRabbit
-
New Features
- Self-hosted deployments now show an encryption-not-configured warning banner on the securities settings page.
- The app also emits a startup warning indicating that sensitive data may be stored unencrypted at rest until encryption is properly enabled.
-
Documentation
- Added localized messaging describing the missing encryption requirements and the setup action to generate encryption keys.
-
Tests
- Added/expanded coverage to verify the banner behavior for self-hosted vs managed deployments.