How to Configure DuckDB Least Privilege
To set up duckdb least privilege, restrict host file permissions and open database files in read-only mode. You also need to scope down cloud storage keys used for remote file reads. Many data teams run this embedded engine with broad local user accounts or admin cloud keys. When permissions are too wide, any user can drop tables, change local files, or pull sensitive data. How native duckdb least privilege works in practice Unlike server databases, this engine runs inside your host app or lo
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
To set up duckdb least privilege, restrict host file permissions and open database files in read-only mode. You also need to scope down cloud storage keys used for remote file reads. Many data teams run this embedded engine with broad local user accounts or admin cloud keys. When permissions are too wide, any user can drop tables, change local files, or pull sensitive data.
How native duckdb least privilege works in practice
Unlike server databases, this engine runs inside your host app or local process. It does not have a built-in user table or role system of its own. Instead, it inherits every permission from the operating system user that starts the process. If the host user can edit a file, the database process can edit that file too.
Setting up duckdb least privilege starts at the operating system level. You create a dedicated service account on the host machine with minimal folder rights. You grant this account read access to specific data folders and block access to system directories. Next, you configure the engine to open the database file in read-only mode. This stops users and apps from changing or deleting tables during a session.
You should also lock down external access features inside the engine settings. By default, a session can read local CSV or Parquet files from the host disk. Turning off external file access stops users from reading arbitrary files outside the main database file. You can also lock the engine settings after startup so users cannot turn protections back on.
Scoping cloud storage roles for remote queries
Many teams use this engine to query Parquet files stored in cloud object buckets. In this setup, the engine uses cloud identity keys to fetch remote data. If you pass a broad cloud key to the session, the user can read every bucket.
To keep access tight, create a dedicated cloud role for each workload or team. Grant that role read-only permissions to the exact bucket prefix needed for the job. Never store long-lived cloud keys in plain text on the host machine. Instead, attach the scoped role to the compute instance or pass temporary credentials at start time. You should also block the engine from loading untrusted community extensions from the internet. Only allow signed extensions that your security team has checked and approved ahead of time.
Least Privilege Principle + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native file and role controls leave open
OS file rules and cloud roles control which files a process can open at startup. They work well when a single app runs fixed queries with no human input. Still, they do not inspect what individual queries do once the file is open.
If an analyst or AI agent has read access to a file, they can query every column. Native file controls cannot hide specific columns or rewrite sensitive rows on the fly. A user with read access can dump full tables containing emails, phone numbers, or card numbers. Also, local embedded sessions do not send central audit logs of every SQL statement by default. When ten engineers share a read-only host role, you cannot tell who ran a specific query. Static file permissions decide who opens the database, not what happens inside the active session.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Does DuckDB have built-in users and roles like Postgres?
No, it is an embedded engine and does not manage its own database users or roles. Access control relies on operating system file permissions, read-only modes, and scoped cloud storage roles.
How do I stop users from reading local host files through SQL queries?
Run the process under a locked-down OS user account and disable external file access in settings. Then lock the engine config so the user cannot change that rule during their session.
Can native read-only mode protect sensitive columns like emails or card numbers?
No, read-only mode only stops users from writing or deleting data in the file. Any user who can read the file can still select all columns unless another tool rewrites results.
Related guides
In this post