Security model

fonctionnel

Trust, per-run checks, the encrypted result cache, the audit log, export redaction, and what a hostile notebook file cannot do.

A notebook from another computer opens behind the trust banner; trusting it read-only; a cell whose SQL changes data stays blocked until Allow writes; a shared notebook asks to map its connections.

Real recording · typing sped up · Northwind demo data

Open the walkthrough on its own page

A notebook is a file full of SQL that someone else may have written, so SQLly treats it the way you'd treat a script from the internet: nothing runs until you've decided it may, every run is checked at the moment it starts, and nothing sensitive leaves your computer without you seeing it first. This page collects those rules in one place.

Trust

Trust is recorded on your computer, not in the file. When you create a notebook in SQLly, it is trusted as you edit and save it. Any other notebook opens non fiable: one saved on another computer, imported from Jupyter, sent by a colleague, or one whose queries or connections were changed outside SQLly after you trusted it (a git pull, a synced folder, another editor). An untrusted notebook shows a banner and runs nothing; you can read every cell first.

Trust notebook opens a dialog that lists every connection the notebook uses and the connection on your computer each one maps to. Untick any it shouldn't use, choose full trust or read-only trust (only cells that don't change data may run), and tick Allow cells that change data only if it needs to. Walkthrough: Connections and safety.

SQLly
Trust this notebook dialog with two connections tickedTrust this notebook dialog with two connections ticked
The trust dialog: each connection the notebook uses, the local connection it maps to, full or read-only trust, and whether cells that change data may run.
  • What trust covers. A trust record is tied to a fingerprint of everything that can run: cell ids, names, kinds and order, every non-Markdown source, connection slots and what they map to, safety policies, cell settings, parameters and the run mode. Markdown text, the title and collapsed cells are not part of it, so editing prose keeps a notebook trusted.
  • Copying can't forge it. Nothing in the file says "trusted". Copying cells or settings out of a trusted notebook into another file does not make that file trusted.
  • A copied id borrows nothing. Run history, local data, approved attachment files and cloud AI consent belong to the trust record, not to the notebook id written in the file. A file that reuses another notebook's id (a copied file, the original left behind by Save As, or a forged id) sees none of them. The first time you save such a copy, it takes a new id of its own, and SQLly says so once; the file this computer already knew keeps its history.
  • Remapping needs a new OK. If you point one of a notebook's connections at a different connection after trusting it, that connection waits for you to allow it again.
  • Trust records live in trust.json in SQLly's notebook data folder, readable only by you, with up to eight trusted versions kept per notebook. A notebook you created but never saved is forgotten after 30 days unless it still has a recovery copy.

Every action is checked when it happens

Trust alone doesn't let a cell run. Right before each cell runs, SQLly checks it again with the notebook's current trust and the connection's current facts, so a decision made earlier can't be replayed after something changed. The checks, in order:

  1. Markdown, parameter and dashboard cells are always fine; Python and kinds this version doesn't know never run.
  2. An untrusted notebook runs nothing.
  3. Cells that compute on results already in the notebook (charts, tables, pivots, KPIs, formulas, transforms, profiles, tests, diffs, attachments, local data cells) run; AI cells then get their own checks for what they may query and share. A diff that re-runs a query on a connection goes through the connection checks below for that connection too.
  4. A cell whose connection isn't mapped on this computer is refused, and one whose connection wasn't allowed, or was remapped since, waits for you to allow it.
  5. A read-only cell whose SQL changes data is refused before the database sees it. Plan cells always capture their plan read-only, and only for a single statement.
  6. A cell that changes data is refused under read-only trust, and needs its own Allow writes otherwise. On production, the connection's production guard and the change review still apply.

Exports, copying results into local data, sharing with a cloud AI model, schedules, parameter sweeps and presenting a dashboard go through the same kind of check. A sweep (a plan cell timing its query over several parameter values) passes every check a run does, refuses cells that change data ("This cell changes data, so it can't be timed: every run would repeat the change."), caps the number of runs, and asks before timing a query on a production connection. Copying into local data never runs a cell that may change data again; it uses the complete result on screen or refuses. Schedules need full trust and no cells that change data, and production only when you allow it explicitly; a notebook with cells that change data can't be shown in the dashboard viewer or presented.

"Changes data" is judged from the SQL text. SQLly classifies statements by their keywords for each engine, which can be fooled by a procedure call that writes. The real guard for a read-only cell is the database's own read-only session that SQLly opens for it; the SQL check is there to stop obvious writes early and explain why.

What a hostile notebook file can't do

  • Run on open. Opening, previewing and reading a notebook never runs SQL and never connects to a database.
  • Carry credentials into your connections. Connections in a notebook are only ids and labels. Before a file is parsed, SQLly's safety check refuses a file whose connection entries contain passwords or connection strings, along with files over 32 MiB, nested more than 64 levels, with strings over 4 MiB, more than 5,000 cells, 500 parameters or 100 connections, and attachment paths that are absolute, point to another drive or share, or climb out of the notebook's folder with ... The check runs on everything the app opens (files, recent files, restored sessions, recovery copies and the browser build), which refuses with "This notebook was not opened because it may be unsafe: …", and on every sqlly-cli notebook run et validate. It also warns about scripts and remote resources in Markdown, auto-run settings, embedded results and secret-looking text; the app shows those in a banner under the trust banner ("SQLLY's safety check found something to look at in this file:") and in the activity panel, until you dismiss it.
  • Leave the notebook's folder through a link. Attachment paths are resolved to their real location first, so a folder shortcut or symbolic link inside the notebook's folder can't lead outside it.
  • Load anything from the web. Markdown never fetches images: an attachment: picture shows the attachment's checked file, and any other image is a small placeholder. See Local data.
  • Read your files through DuckDB. The notebook's local database can't open files outside its own folder, install or load extensions, attach other databases or change its settings; see Local data.
  • Talk the AI into more permissions. Text in cells and in your data reaches the AI agent fenced off as data, which makes planted instructions harder to slip in but can't rule out that the model is misled. What it may do doesn't depend on that: the agent has no tool that writes, exports or reaches the network, which connections it may query comes from the notebook's trust, never from what the model says, and every change it proposes waits for you. See The AI notebook agent.
SQLly
Safety check warning banner on a newly opened notebookSafety check warning banner on a newly opened notebook
A notebook whose Markdown links an image on the web opens with the safety check's warning under the trust banner.

Saved results are encrypted and scoped

Results that SQLly keeps on disk (cell results you choose to save, pinned snapshots, and the outputs of runs from the app, the CLI and schedules) are encrypted with XChaCha20-Poly1305 using a key kept in your system keychain (Keychain on macOS, Credential Manager on Windows, Secret Service on Linux). Each result is filed under a keyed scope made from the connection, the database, the login that fetched it and the safety settings, so another login or role never sees it, and changing an id in a file can't reach someone else's results. A damaged, altered or renamed file is discarded instead of read. Results expire, the oldest are removed when the cache passes its size limit (pinned snapshots are kept), and you can clear them per connection or all at once. If the keychain can't be reached, results stay in memory for the session and the reason is shown. An untrusted notebook shows no saved results at all.

A notebook's local DuckDB database can be encrypted too: switch on Encrypt local data on the left rail's Local data page. Its key is kept in the system keychain under the notebook's data scope, and sqlly-cli opens the database with the same key. A DuckDB file can't be encrypted in place, so the switch only works while the notebook has no local tables; with tables, SQLly asks you to clear local data first, and the tables come back when their cells run again. See Local data with DuckDB.

The audit log

Every cell run, refusal, trust decision, parameter sweep and export in the app, and every run, schedule and export from the CLI, is written as one JSON line to the notebook audit log (audit/audit.jsonl in the notebook data folder, readable only by you, rotated by size). An entry records the time, who (your operating-system user name), the notebook and its version, the action, the decision and the reason, the cell, the connection and its environment, row and byte counts, duration, a hash of the SQL (taken with sensitive parameter values left out, so it can't be used to guess them), and the outcome. Export entries add the format, what was exported, whether it was structure only and what redaction removed, never the data. The SQL text itself is never written by default, and errors are masked for secrets and shortened.

Redaction on export and sharing

Before any export, SQLly removes sensitive parameter values, sensitive columns (by their classification and by names such as password ou ssn), anything in SQL, settings or results that looks like a password, private key, access token or connection-string secret, and your computer's connection mappings, then lists what it removed. Exporting sensitive data, or sending it to another service, asks first. The same rules decide what a cloud AI model may be shown. See Exporting.

Limites

  • In the browser build, notebooks and trust records live in the browser's storage for the site, so trust there is only as strong as that site's own security.
  • Trust records are protected by file permissions only. Anyone who can write to your user data folder can already change SQLly's settings.
  • Deleting a cached result overwrites it with zeros first, which is best effort on SSDs and copy-on-write file systems.
  • The audit log names your operating-system user, not a signed-in SQLly account, and there is no setting yet to include SQL text in it.
  • An older .sqlnb.json notebook without a stored id opens untrusted every time until you save it as .sqllynb.