sqldb: wire up PragmaOptions config for SQLite store
What changed, and why it matters
This commit fixes a configuration bug in LND's new SQLite-based database layer. A setting called PragmaOptions existed in the config but was being silently ignored when building the database connection string. The change now appends those user-specified SQLite pragma options, matching how the older key-value SQLite store already behaves. Pragmas control low-level database behavior such as locking modes, journal settings, and synchronous levels, so honoring the user's choices matters for both correctness and security hardening.
Treat as a hardening/reliability fix. Review whether any deployment relied on PragmaOptions for security-sensitive pragmas and verify those pragmas are now active. Consider adding validation or an allow-list for user-supplied pragma options to prevent unsafe values from being passed directly into the DSN.
Security signals we found
Configuration value was silently ignored, potentially weakening intended security/integrity settings
User-supplied SQLite pragmas (e.g., synchronous, journal_mode, secure_delete) now take effect
Fixes behavioral inconsistency between kvdb/sqlite and sqldb/sqlite backends
No input validation or allow-listing added for pragma options
Evidence from the diff
In sqldb/sqlite.go, NewSqliteStore builds a DSN for modernc.org/sqlite by adding built-in pragma options, then constructing the connection URL. The SqliteConfig struct already had a PragmaOptions []string field, but the loop to append those options to sqliteOptions was missing. The patch adds the loop after the built-in options, using sqliteOptionPrefix for each entry. This aligns the SQL database backend with kvdb/sqlite, which already applies user pragmas. The change is small (+6 lines) and purely functional; it does not add validation of the pragma strings.
Changed components
sqldb/sqlite.goLND SQLite database backendSqliteConfig.PragmaOptionsInspect captured patch +6 / −0
diff --git a/sqldb/sqlite.go b/sqldb/sqlite.go
index fc724e9..ede2999 100644
--- a/sqldb/sqlite.go
+++ b/sqldb/sqlite.go
@@ -100,6 +100,12 @@ func NewSqliteStore(cfg *SqliteConfig, dbPath string) (*SqliteStore, error) {
)
}
+ // Then we add any user specified pragma options. Note that these can
+ // be of the form: "key=value", "key(N)" or "key".
+ for _, option := range cfg.PragmaOptions {
+ sqliteOptions.Add(sqliteOptionPrefix, option)
+ }
+
// Construct the DSN which is just the database file name, appended
// with the series of pragma options as a query URL string. For more
// details on the formatting here, see the modernc.org/sqlite docs:
Why this scored 27/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.