Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

docs: clarify unencrypted fallback authentication limits (#6908)

LearningCircuitc3f997b29dd4
diff --git a/README.md b/README.md
index 23ca4159d5..4b2de0f0f8 100644
--- a/README.md
+++ b/README.md
@@ -95,7 +95,7 @@ python -m local_deep_research.web.app # starts the web UI on http://localhost:
> You'll also need Ollama (or any OpenAI-compatible LLM endpoint) and SearXNG running — see the [pip install guide](docs/install-pip.md) for the full recipe.
> Works on Windows, macOS, and Linux. SQLCipher encryption is included via pre-built wheels — no compilation needed.
> PDF export on Windows requires Pango ([setup guide](https://doc.courtbouillon.org/weasyprint/stable/first_steps.html)).
-> If you encounter issues with encryption, set `export LDR_BOOTSTRAP_ALLOW_UNENCRYPTED=true` to use standard SQLite instead.
+> **Development fallback:** `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED=true` permits plaintext SQLite only when SQLCipher is unavailable or nonfunctional; working SQLCipher still takes priority. The fallback does not verify account passwords and is unsuitable for shared deployments. See [fallback limitations](docs/developing.md#unencrypted-development-fallback).
**Detailed install guides:** [Docker](docs/installation.md#docker) · [Docker Compose](docs/docker-compose-guide.md) · [pip](docs/install-pip.md) · [Unraid](docs/deployment/unraid.md) · [full install reference](docs/installation.md)
diff --git a/SECURITY.md b/SECURITY.md
index 2a0ad9d6f1..90eb08aec5 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -60,6 +60,14 @@ This project processes user queries and search results. Key areas:
Local Deep Research uses **SQLCipher** (AES-256-CBC) for database encryption. Each user's database is encrypted with their login password as the key, derived via PBKDF2-HMAC-SHA512 with 256,000 iterations and a per-user random salt. There is no separate password hash — authentication works by attempting to decrypt the database. API keys stored in the database are encrypted at rest.
+**Development fallback:** `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED=true` permits
+plaintext SQLite only when SQLCipher is unavailable or nonfunctional; it
+does not override working SQLCipher. In this fallback, database opens do
+not verify account passwords, including when a connection is already cached.
+The login form therefore does not provide equivalent account authentication.
+Use the fallback only for isolated local development, not shared hosting.
+See [fallback limitations](docs/developing.md#unencrypted-development-fallback).
+
### In-Memory Credentials
Like all applications that use secrets at runtime — including [password managers](https://www.ise.io/casestudies/password-manager-hacking/), browsers, and API clients — credentials are held in plain text in process memory during active sessions. This is an [industry-wide reality](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) acknowledged by [OWASP](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html), [Microsoft](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-security-securestring) (who deprecated `SecureString` for this reason), and the [pyca/cryptography](https://cryptography.io/en/stable/limitations/) library.
diff --git a/changelog.d/6735.misc.md b/changelog.d/6735.misc.md
new file mode 100644
index 0000000000..a48da5cc0b
--- /dev/null
+++ b/changelog.d/6735.misc.md
@@ -0,0 +1,4 @@
+Clarified that `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED` only permits a development
+fallback when SQLCipher is unavailable or nonfunctional. The fallback
+stores plaintext and does not verify account passwords, so it is
+unsuitable for shared hosting.
diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md
index 68cd2edec5..9ca0d6b6a7 100644
--- a/docs/CONFIGURATION.md
+++ b/docs/CONFIGURATION.md
@@ -18,7 +18,7 @@ They are not available in the Web UI because they are needed to start the applic
| Environment Variable | Type | Default | Required | Constraints | Description | Category | Deprecated Alias |
|----------------------|------|---------|----------|-------------|-------------|----------|------------------|
-| `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED` | Boolean | `False` | No | | Allow unencrypted database (for development) | Bootstrap | LDR_ALLOW_UNENCRYPTED |
+| `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED` | Boolean | `False` | No | | Allow plaintext SQLite for isolated local development when SQLCipher is unavailable or nonfunctional. Working SQLCipher still takes priority; the fallback does not verify account passwords. | Bootstrap | LDR_ALLOW_UNENCRYPTED |
| `LDR_BOOTSTRAP_CONFIG_DIR` | Path | `None` | No | | Configuration directory path | Bootstrap | |
| `LDR_BOOTSTRAP_DATABASE_URL` | String | `None` | No | | Database connection URL | Bootstrap | |
| `LDR_BOOTSTRAP_DATA_DIR` | Path | `None` | No | | Data directory path | Bootstrap | |
diff --git a/docs/SQLCIPHER_INSTALL.md b/docs/SQLCIPHER_INSTALL.md
index 25d3ef7ad4..df50d1b118 100644
--- a/docs/SQLCIPHER_INSTALL.md
+++ b/docs/SQLCIPHER_INSTALL.md
@@ -97,7 +97,14 @@ python -c "from local_deep_research.database.sqlcipher_compat import get_sqlciph
## Fallback Mode
-If SQLCipher is not available, Local Deep Research will fall back to using regular SQLite databases. However, this means your data will not be encrypted at rest. A warning will be displayed when running without encryption.
+There is no automatic fallback. If SQLCipher is unavailable or nonfunctional, startup stops with an error by default.
+
+Setting `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED=true` permits plaintext SQLite in that case only; working SQLCipher still takes priority. This fallback is for isolated local development, not shared or family hosting:
+
+- Database contents, including stored API keys, are not encrypted at rest.
+- Account passwords are not verified: a different nonblank password can open an existing plaintext user database.
+
+A warning is logged at startup while running in this fallback. See [Unencrypted Development Fallback](developing.md#unencrypted-development-fallback) for details.
## Security Notes
diff --git a/docs/developing.md b/docs/developing.md
index cabc40377f..d460e635d4 100644
--- a/docs/developing.md
+++ b/docs/developing.md
@@ -81,10 +81,34 @@ For local development and testing, you may want to configure these environment v
| Variable | Default | Description |
|----------|---------|-------------|
| `LDR_DATA_DIR` | Platform default | Override data/database storage location |
-| `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED` | `false` | Allow unencrypted database (dev only!) |
+| `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED` | `false` | Permit plaintext SQLite if SQLCipher is unavailable or nonfunctional; no account-password verification (isolated local development only) |
| `CI` or `TESTING` | unset | Enables testing mode (bypasses some security checks) |
-> **Warning**: Never set `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED=true` in production. User data will be stored unencrypted.
+### Unencrypted Development Fallback
+
+`LDR_BOOTSTRAP_ALLOW_UNENCRYPTED` controls what happens when the SQLCipher
+startup check fails. It is not a switch to disable encryption:
+
+- Working SQLCipher takes priority, even when the flag is `true`, including
+ for newly created databases in the standard Docker image.
+- If SQLCipher is unavailable or nonfunctional, the default `false` stops
+ startup. Setting the flag to `true` permits plaintext SQLite instead.
+- The flag does not convert existing encrypted databases to plaintext or
+ allow SQLite to decrypt them.
+
+**The fallback also lacks account-password verification.** LDR normally
+verifies a login password by unlocking the user's SQLCipher database, or by
+checking an in-memory verifier for an already-open encrypted connection.
+There is no separate persisted password hash. In the SQLite fallback,
+neither a fresh database open nor a cached connection verifies the supplied
+password. Rejecting blank input is not a credential check: a different
+nonblank password can still open an existing plaintext user database.
+
+Use this fallback only for isolated local development with disposable data.
+Database contents, including stored API keys, are plaintext. Do not remove
+SQLCipher to use it for shared or family hosting; a supported shared plaintext
+deployment must provide independent account authentication. Filesystem
+encryption does not supply that missing login check.
### Docker (Production-like)
diff --git a/docs/install-pip.md b/docs/install-pip.md
index fb38501637..8071533c9f 100644
--- a/docs/install-pip.md
+++ b/docs/install-pip.md
@@ -39,7 +39,7 @@ Open http://localhost:5000 after a few seconds.
LDR uses SQLCipher for AES-256 encrypted databases. Pre-built `sqlcipher3` wheels are available for Windows, macOS, and Linux — most users won't need to compile anything.
- **Full setup instructions:** [SQLCipher Install Guide](SQLCIPHER_INSTALL.md)
-- **Skip encryption:** If you don't need database encryption, set `export LDR_BOOTSTRAP_ALLOW_UNENCRYPTED=true` to use standard SQLite instead. API keys and data will be stored unencrypted.
+- **Development fallback:** `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED=true` permits standard SQLite only when SQLCipher is unavailable or nonfunctional. It does not disable working SQLCipher. In the fallback, database contents (including stored API keys) are plaintext and account passwords are not verified. Use it only for isolated local development, not shared or family hosting. See [fallback limitations](developing.md#unencrypted-development-fallback).
- **Docker:** Includes SQLCipher out of the box — no extra setup needed.
## Optional Dependencies
diff --git a/src/local_deep_research/database/encrypted_db.py b/src/local_deep_research/database/encrypted_db.py
index a08319d0b3..abb3fd6d22 100644
--- a/src/local_deep_research/database/encrypted_db.py
+++ b/src/local_deep_research/database/encrypted_db.py
@@ -440,7 +440,18 @@ class DatabaseManager:
return username in self.connections
def _check_encryption_available(self) -> bool:
- """Check if SQLCipher is available for encryption."""
+ """Probe SQLCipher before considering the development fallback.
+
+ Working SQLCipher always returns True, even when
+ ``LDR_BOOTSTRAP_ALLOW_UNENCRYPTED`` is enabled. The flag is consulted
+ only if the probe fails; it permits plaintext SQLite instead of a
+ startup error. It neither forces plaintext storage nor converts an
+ existing encrypted database.
+
+ Returning False also removes password verification from database
+ opens: SQLite has no credential to check. This fallback is for
+ isolated local development, not authenticated shared deployments.
+ """
try:
import os as os_module
import tempfile
@@ -656,6 +667,10 @@ class DatabaseManager:
"""Create a new database for a user (encrypted, or the unencrypted
fallback when SQLCipher is unavailable).
+ In the plaintext fallback, accepting a nonblank ``password`` does
+ not establish a credential for later logins. Subsequent database
+ opens do not verify it; see :meth:`open_user_database`.
+
Serialized per user by the same init lock that guards cold opens:
two concurrent creates for one username used to both pass the
``db_path.exists()`` guard, and the loser's orphaned-salt recovery
@@ -1283,7 +1298,20 @@ class DatabaseManager:
def open_user_database(
self, username: str, password: str
) -> Optional[Engine]:
- """Open an existing encrypted database for a user."""
+ """Open a user's database, verifying the password only with SQLCipher.
+
+ With encryption enabled, a cold open validates the derived key
+ against the database; a cached open requires a matching in-memory
+ password verifier. An already-open database alone is not proof of
+ the caller's password.
+
+ In the plaintext development fallback, neither cold nor cached
+ opens verify the account password. The nonblank-input check below
+ still applies, but a different password can open the same database.
+ A returned engine in that mode is not evidence of authentication.
+ Callers must not use this fallback for shared accounts that rely on
+ LDR password verification without adding independent authentication.
+ """
open_start = time.perf_counter()
# Validate the encryption key
@@ -1455,7 +1483,9 @@ class DatabaseManager:
logger.warning(
f"SQLCipher not available - opening UNENCRYPTED database for user {username}"
)
- # Fall back to regular SQLite (no password protection!)
+ # SQLite does not use hex_key. Deriving it above is not password
+ # verification: this fallback opens the database independently
+ # of the supplied nonblank password.
engine = create_engine(
f"sqlite:///{db_path}",
connect_args={"check_same_thread": False, "timeout": 30},
diff --git a/src/local_deep_research/settings/env_definitions/bootstrap.py b/src/local_deep_research/settings/env_definitions/bootstrap.py
index 0969c724c6..df07c8bb73 100644
--- a/src/local_deep_research/settings/env_definitions/bootstrap.py
+++ b/src/local_deep_research/settings/env_definitions/bootstrap.py
@@ -32,7 +32,11 @@ BOOTSTRAP_SETTINGS = [
),
BooleanSetting(
key="bootstrap.allow_unencrypted",
- description="Allow unencrypted database (for development)",
+ description=(
+ "Allow plaintext SQLite for isolated local development when "
+ "SQLCipher is unavailable or nonfunctional. Working SQLCipher "
+ "still takes priority; the fallback does not verify account passwords."
+ ),
default=False,
deprecated_env_var="LDR_ALLOW_UNENCRYPTED",
),
diff --git a/src/local_deep_research/web/routers/auth.py b/src/local_deep_research/web/routers/auth.py
index 3982c49188..27432a257c 100644
--- a/src/local_deep_research/web/routers/auth.py
+++ b/src/local_deep_research/web/routers/auth.py
@@ -201,7 +201,11 @@ def login(
status_code=429,
)
- # Try to open user's encrypted database. Two distinct failure modes:
+ # Opening the database is this route's password check only with SQLCipher.
+ # The plaintext development fallback has no independent credential check:
+ # a successful open there does not prove the caller knows the account's
+ # password. A supported shared plaintext mode needs separate authentication.
+ # With SQLCipher, distinguish these two failure modes:
# - return None → credentials invalid OR DB missing → 401, count toward lockout
# - raise DatabaseInitializationError → credentials valid but schema
# can't be brought up (e.g. world-writable migrations dir tripping
diff --git a/tests/security/test_db_connection_unencrypted_mode.py b/tests/security/test_db_connection_unencrypted_mode.py
index 0e473ebd52..47e582398e 100644
--- a/tests/security/test_db_connection_unencrypted_mode.py
+++ b/tests/security/test_db_connection_unencrypted_mode.py
@@ -23,7 +23,11 @@ construction, per the round-5 instructions):
SQLCipher-only pragma when ``has_encryption`` is False, so this is a
plain regression test.
-A U3 "wrong password against a warm cache succeeds" test was dropped: it
+* U3 a COLD open (no cached engine) with a different nonblank password
+ succeeds, as docs/developing.md#unencrypted-development-fallback
+ states: the fallback ``sqlite:///`` path never uses the derived key.
+
+A "wrong password against a warm cache succeeds" test was dropped: it
duplicated ``test_login_cached_connection_password_extra.py``'s
``test_unencrypted_mode_reuses_cached_engine``.
@@ -169,3 +173,38 @@ def test_check_database_integrity_reports_healthy_unencrypted_database(
)
assert unenc_manager.check_database_integrity(username) is True
+
+
+def test_cold_open_with_different_password_succeeds(unenc_manager):
+ """U3: no credential check on a fresh open in the fallback.
+
+ U1 only uses a different password on a cache hit. Here the engine is
+ closed first, so the different password goes through the cold path.
+ """
+ username = f"unenccold_{uuid.uuid4().hex[:8]}"
+ engine = unenc_manager.create_user_database(username, "ColdOpenPw1!") # noqa: S105
+ with engine.begin() as conn:
+ conn.execute(
+ text("CREATE TABLE gap_u_cold (id INTEGER PRIMARY KEY, note TEXT)")
+ )
+ conn.execute(text("INSERT INTO gap_u_cold VALUES (1, 'gap-U3')"))
+ unenc_manager.close_user_database(username)
+ assert not unenc_manager.is_user_connected(username), (
+ "setup: the cold path needs no cached engine"
+ )
+
+ reopened = unenc_manager.open_user_database(
+ username,
+ "an-entirely-different-password", # noqa: S106
+ )
+ assert reopened is not None, (
+ "the fallback cold open rejected a different nonblank password; "
+ "update docs/developing.md#unencrypted-development-fallback"
+ )
+ with reopened.connect() as conn:
+ assert (
+ conn.execute(
+ text("SELECT note FROM gap_u_cold WHERE id = 1")
+ ).scalar()
+ == "gap-U3"
+ )