Is Turso Safe? Security Analysis
SQLite at the edge
Turso runs libSQL, a fork of SQLite, with edge replication, token-based authentication, and encryption. libSQL inherits SQLite’s extensive test suite.
Unlike a traditional SQLite deployment, Turso is a managed service accessed over HTTP/WebSocket with replication to edge regions. That network surface is where the Turso-specific risks live.
Security Considerations
Token Management
Use read-only tokens where write access isn’t needed, and store tokens in environment variables. Turso tokens look like JWTs:
eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTk....
Scope each token to the minimum permissions required:
# Read-only token for analytics service
turso db tokens create my-db --read-only --expiration 90d
# Full-access token for application backend
turso db tokens create my-db --expiration 90d
Set an explicit expiration on every token, or you will forget to rotate it. 90 days is a reasonable default; rotate sensitive workloads more often.
Embedded Replicas
The replica is a libSQL file on disk in the application’s working directory. Anyone with read access to that file gets a full copy of everything the replica syncs.
Practical guidance:
- Use embedded replicas for read-only or non-sensitive datasets (product catalogs, public content, reference data)
- Do not put per-user PII in an embedded replica unless you encrypt the file at the OS level (FileVault, BitLocker) and accept that other apps with the same user privileges can still read it
- For mobile apps, use the platform’s secure storage APIs (Keychain on iOS, Keystore on Android) to encrypt the replica file with a key protected by the device passcode or biometrics
Database Groups
Different database groups can have different access tokens. Groups also set per-region replication, so you can keep regulated data (EU customer data, for example) in regions that satisfy your compliance requirements.
A common multi-tenant pattern:
turso group create eu-tenants --location fra
turso db create acme-corp --group eu-tenants
turso db tokens create acme-corp --read-only
Each tenant gets their own database, their own token, and optionally their own region.
SQL Injection
libSQL is still SQLite - it accepts whatever SQL you send. Parameterize:
// BAD
const r = await client.execute(
`SELECT * FROM users WHERE email = '${email}'`
);
// GOOD
const r = await client.execute({
sql: "SELECT * FROM users WHERE email = ?",
args: [email]
});
The Turso SDKs all support parameterized queries.
Token in Edge Functions
Tokens placed in edge function environment variables (Cloudflare Workers, Vercel Edge, Deno Deploy) are server-side and not visible to clients, but they are visible to anyone who can read your function source or your platform’s environment configuration. Rotate when team membership changes, and prefer short-lived tokens for edge deploys when possible.
Replica Sync Conflicts
Embedded replicas sync writes back to the primary. If the application writes to a stale local replica, the conflict resolution defaults to last-write-wins. For data where a lost write is unacceptable (financial balances, inventory), keep writes synchronous against the primary endpoint and use the embedded replica only for reads.
Application Security
Turso secures the database layer. A token grants access to the database; your application decides which user may run which query with which arguments.
Security Assessment
Strengths
-
- libSQL fork of SQLite with security improvements
-
- Encryption at rest for all data
-
- TLS for all connections
-
- Token-based authentication with scoped permissions
-
- Edge replication for global distribution
-
- Database groups for access control
-
- Per-database isolation by default
-
- Token expiration enforced
Concerns
-
- Embedded replicas store a full copy on the device
-
- Token management is the developer’s job
-
- Application security remains your responsibility
-
- No native row-level security - relies on per-tenant databases or app-layer enforcement
-
- Tokens in edge function env are visible to anyone with function source access
-
- Replica sync conflicts can silently overwrite writes
Turso vs Upstash for edge data
Both Turso and Upstash target the same problem: low-latency data access from edge functions. The trade-off is data model.
- Turso (libSQL). Relational. SQL queries, joins, transactions, full-text search. Use when your data needs structure or your queries need expressiveness.
- Upstash (Redis). Key-value with rich data structures. Use for caching, sessions, rate limiting, queues, pub/sub.
Security-wise the models are similar: HTTP API, scoped tokens, TLS by default. Both fail through a leaked token, and both are protected by short-lived, narrowly scoped tokens stored only server-side.
Common Turso mistakes
Token without expiration. Generated during setup, never rotated, and still valid when an old laptop is recycled.
Embedded replica with PII. Mobile app embeds a replica of the user table for offline access. Replica file is unencrypted on the device. If the phone is jailbroken or backed up to cloud, the full user table can be extracted.
Read-only token shipped to browser. Static site embeds a read-only token to query public content. The token is also valid for every other table in the database, including an admin table that should have been in a separate database.
Single token for all tenants. Application uses one full-access token for all tenants and enforces isolation in code. A bug in the isolation code leaks across tenants. Per-tenant tokens against per-tenant databases remove that failure mode.
The Verdict
Turso is safe to run in production if you scope and expire tokens and treat embedded replicas as readable copies of your data.
Four checks before production:
- Every token has an explicit expiration and a documented rotation schedule.
- Read-only tokens are used wherever write access isn’t required.
- Embedded replicas contain only data acceptable to leak if the device is compromised.
- Each tenant’s data is in its own database (or, if shared, every query has an enforced tenant filter).
Related Resources
How to Secure Turso
Step-by-step security guide covering token rotation, embedded replica encryption, and database group design.
Turso Security Checklist
Interactive security checklist for production Turso deployments.
Token Leak Checker
Find Turso tokens exposed in browser bundles or public repos.
Is Upstash Safe?
Comparison with the other major edge data option.
Scan Your Application
VibeEval scans your application for token leaks and runs SQL injection probes against your Turso-backed routes.
Common questions
Is Turso safe to use in production?
What is libSQL and how does it differ from SQLite?
How do Turso auth tokens work?
Should I use read-only tokens for client-side code?
What are embedded replicas and what is the security risk?
Does Turso support row-level security?
How are Turso databases isolated from other customers?
How does Turso compare to Upstash for edge data?
Scan your deployed app
Paste your live URL. We probe exposed keys, missing auth, open databases, and broken access control - results in under 60 seconds. 14-day trial.
14-day free trial · Cancel anytime