Security model
What Safeslice guarantees, what it does not, how it treats credentials, and the threat model behind those choices.
Safeslice points at production by definition. Everything below is a design decision made on that basis.
The source is opened read-only
SET default_transaction_read_only = on
This runs before anything else, on every connection to the source. No bug in this tool — and no predicate you paste into --where — can write to it. Point it at a read replica and it works unchanged.
The whole read side runs inside one REPEATABLE READ transaction, and the key closure is kept in a local SQLite file rather than a temp table on the source, so no write permission is needed anywhere.
It refuses to write to the source
If the target resolves to the same host, port and database as the source, the run stops before it starts. Sliced-and-masked data loaded back over production is not a recoverable mistake.
Destructive target operations require typing the name
Replacing an existing target database drops it. That is confirmed by typing the database name, not by y/N — a yes/no prompt is answered by reflex.
Credentials
- Connection strings are reduced to host, port, database and user before reaching any log, report, terminal line or saved profile.
- Passwords typed at the prompt are never echoed and never written to disk.
- Saved connections in
.safeslice/store the DSN with the password stripped; a connection that needs one records the name of an environment variable instead. pg_dumpandpsqlare invoked with credentials in the environment, never inargv, so they do not appear inps.- A test walks every generated artifact asserting the password never appears in any of them.
What Safeslice does not do
- It does not guarantee that no personal data exists in the output. See below.
- It does not encrypt the target database. That is your platform’s job.
- It does not manage access to the development database it creates.
- It does not phone home. There is no telemetry of any kind: no usage counters, no error reporting, no update check.
The claim it will not make
Safeslice verifies configured and detectable personal-data patterns and surfaces uncertain fields for review. Verification is a safety check, not a mathematical proof that arbitrary free text contains no personal data.
A tool that told you “zero PII guaranteed” would be lying, because free text cannot be checked that way. What Safeslice does instead is refuse to run — by default — while any text column remains unreviewed, so the decision is made by a person who can be asked about it later.
Threat model
| Concern | Mitigation |
|---|---|
| Tool writes to production | Read-only session, enforced by the server |
| Slice loaded back over production | Refuses when source and target resolve to the same database |
| Credentials in logs, reports or CI output | DSNs redacted at every boundary; asserted by test |
| Credentials in the process table | Child processes receive credentials via environment |
| Personal data surviving masking | Deterministic rules per column, plus a post-load scan |
| Free text nobody looked at | strict mode halts the run |
| Someone else’s target overwritten | Explicit confirmation naming the database |
| Supply chain | Reproducible builds from a tagged commit, checksums published per release |
Reporting a vulnerability
See SECURITY.md in the repository. Please do not open a public issue for a security report.