Documentation/Security

Security

DBCraft holds credentials to your production databases, so it ships locked down. These are the controls built into the product, and the settings worth checking before you go live.

Encrypted credentials

  • Data source credentials and AI provider keys are encrypted with AES-256-GCM, with a fresh nonce on every write and tamper detection on every read.
  • Ciphertexts use a versioned envelope, so the scheme and key can be rotated without a flag day.
  • Keys are derived per purpose: a data source credential can never be decrypted as an AI key, or the other way round.
  • Upgrading from an older release re-encrypts any legacy values in place on first boot.

Durable secrets

  • If you set DBCRAFT__AUTH__JWT_SECRET and DBCRAFT__SECURITY__ENCRYPTION_KEY, they win.
  • If you do not, DBCraft generates them once and persists them to .dbcraft_secrets.json (mode 0600) in the data directory, so restarts keep sessions and credentials working.
  • Back up the encryption key. Stored credentials cannot be recovered without it.

Access control on every path

  • Every query, schema, sample and export request checks that the caller may use that data source: its creator, members of the creator's organisation, or holders of an explicit grant.
  • An explicit grant of 'none' is a denial. Denied data sources return not found, so ids cannot be probed.
  • Dashboard grants and edit history are visible only to people who can administer that dashboard.
  • Self-service registration is off by default. The first user bootstraps the install; everyone after that is created by an admin or invited.

Query guardrails

  • Read-only mode is on by default and rejects writes to connected databases.
  • Every query has a deadline (30 seconds by default, 5 minutes at most) and a row limit (10,000 by default, 100,000 at most).
  • Filter values on public dashboards are rendered as typed SQL literals, never pasted into the query as text.

Personal data masking

  • Every query result and export is classified column by column. Card numbers (Luhn-checked) are always masked to the last four digits.
  • Emails, phone numbers, names, postal addresses, postcodes, dates of birth, bank account numbers, sort codes, IBANs, National Insurance numbers and government IDs are masked by default.
  • Literal values are stripped from SQL before it is written to query history or sent to an AI provider. History is pruned after 90 days by default.
  • The same masking applies to dashboards, public links and the MCP server.

Sign-in and sessions

  • Passwords need at least 12 characters.
  • Accounts lock for 30 minutes after 10 failed sign-ins.
  • Sessions end after 15 minutes of inactivity. Access tokens last 5 minutes and are refreshed against a server-side session record.
  • Signing out revokes the session on the server, not just in the browser.
  • Passwords on shared dashboards are hashed with Argon2id, and attempts are rate limited.

Browser hardening

  • CORS is same-origin by default. Extra origins are opt-in.
  • A Content Security Policy that loads scripts only from your own server, blocks framing by other sites (frame-ancestors 'self'), and HSTS when served over HTTPS.
  • The Monaco SQL editor is bundled and served from your own server, not a CDN. The only third-party origin the app loads from is Google Fonts.

Audit trail

  • Sign-ins, sign-outs and failed attempts (including from unknown accounts), password changes and resets, user and invitation lifecycle, organisation changes, data source changes and query execution are all recorded.
  • The event set follows PCI DSS v4.0.1 Requirement 10.2.

Build pipeline

  • Release images ship with an SPDX SBOM and are signed with cosign, with the SBOM attached as a signed attestation.
  • CI runs cargo audit and pnpm audit, gates test coverage on security-critical modules, and builds the container on every pull request.

Production checklist

VariableValueWhy
DBCRAFT__SECURITY__ENCRYPTION_KEYopenssl rand -base64 48Set it, then back it up.
DBCRAFT__AUTH__JWT_SECRETopenssl rand -base64 48Changing it signs everyone out.
DBCRAFT__SERVER__BASE_URLhttps://dbcraft.example.comHTTPS enables secure cookies and HSTS.
DBCRAFT__QUERY__READ_ONLY_MODEtrueDefault. Leave it on.
DBCRAFT__AUTH__ALLOW_REGISTRATIONfalseDefault. Invite people instead.
DBCRAFT__SECURITY__CORS_ALLOWED_ORIGINS(empty)Same-origin only unless you need more.
DBCRAFT__SECURITY__FRAME_ANCESTORS'self'Widen only to embed dashboards elsewhere.

Configuration is read only from variables with the DBCRAFT__ prefix. A bare JWT_SECRET or ENCRYPTION_KEY is ignored.

PCI DSS and compliance

DBCraft implements the application-level technical controls that map to PCI DSS v4.0.1: masking and encryption (Requirement 3), injection defences (6.2.4), least-privilege data access (7.2), session and password controls (8.2.8, 8.3.4, 8.3.6) and audit event generation (10.2).

DBCraft is not itself PCI DSS certified and does not give you an Attestation of Compliance. Certification covers your whole environment and organisation: network segmentation, log retention, quarterly ASV scans, penetration testing and policy. Those remain with you and your assessor.

The simplest way to keep your compliance scope small is to connect DBCraft only to read replicas that hold no card data, using a read-only database user.

Not covered yet

  • Multi-factor authentication.
  • Row- and column-level restrictions inside a data source. Access is granted per data source.
  • Enforced TLS to data sources. New connections default to SSL off; set the SSL mode to require on each connection.

Found a vulnerability?

Please email us privately before disclosing it, and we will get back to you quickly.