Turso

Turso Security Best Practices

Secure your Turso edge database with these essential practices. From token management to access control.

Verify your app follows these best practices automatically.

Turso brings SQLite to the edge with replication. These practices help you secure your distributed database properly.

Quick Wins

Audit tokens with 'turso db tokens list'
Replace admin tokens with scoped tokens
Move tokens to environment variables
Review group permissions
Check for raw SQL concatenation in code

Security Best Practices

#1Use Scoped Tokens

critical

Create tokens with minimal permissions for each use case. Don't use admin tokens in applications.

Implementation

Create read-only tokens for queries, write tokens only where needed

Don't do this
# Using admin token everywhere
TURSO_AUTH_TOKEN=admin-token-with-full-access
Do this instead
# Using scoped token
TURSO_AUTH_TOKEN=read-only-token-for-app

#2Store Tokens in Environment Variables

critical

Never hardcode Turso tokens in your application code.

Implementation

Use environment variables, never commit tokens to git

#3Rotate Tokens Regularly

high

Create new tokens periodically and revoke old ones to limit exposure from potential leaks.

Implementation

Set up token rotation schedule, use turso db tokens create/revoke

#4Use Group Access Controls

high

Manage database access through groups for team collaboration.

Implementation

Create groups with appropriate permissions, add members to groups

#5Enable Encryption at Rest

high

Ensure your database data is encrypted when stored.

Implementation

Turso encrypts data at rest by default, verify encryption is enabled

#6Validate All Inputs

high

Use parameterized queries to prevent SQL injection attacks.

Implementation

Use prepared statements, never concatenate user input into queries

Common Mistakes to Avoid

Using admin tokens in applications

Why it's dangerous:

Admin tokens have full access if compromised

How to fix:

Create scoped tokens with minimal permissions

Hardcoding tokens in code

Why it's dangerous:

Tokens get committed to git and exposed

How to fix:

Use environment variables for all tokens

Concatenating user input in queries

Why it's dangerous:

Enables SQL injection attacks

How to fix:

Use parameterized queries with prepared statements

Verify Your Turso App Security

Following best practices is the first step. Verify your app is actually secure with a comprehensive security scan.

Get Starter Scan

Frequently Asked Questions

How secure is Turso?

Turso encrypts data at rest and in transit. Security depends on proper token management and access controls. Use scoped tokens and parameterized queries.

What happens if a token is compromised?

Immediately revoke the token with 'turso db tokens revoke'. Create a new scoped token and update your application. Review audit logs for unauthorized access.

Can I restrict tokens to read-only?

Yes, create tokens with specific permissions. Use read-only tokens for queries and separate tokens for write operations.

Last updated: January 2026