# motherduck-security-governance
> Assess or configure MotherDuck access control, including roles (RBAC), share grants, table-, row-, and column-level security, masking, tenant isolation, residency, and Terraform governance.
Assess or configure MotherDuck access control, including roles (RBAC), share grants, table-, row-, and column-level security, masking, tenant isolation, residency, and Terraform governance.

[Workflow skill](/sql-reference/agent-skills/#workflow-skills) · [View source on GitHub](https://github.com/motherduckdb/agent-skills/tree/v3.4.0/skills/motherduck-security-governance)

:::info

This page shows the skill's `SKILL.md`: the instructions a coding agent loads when a task matches the description above. To install every MotherDuck skill in Claude Code, Codex, Cursor, or Gemini CLI, see [Install MotherDuck Skills](/key-tasks/ai-and-motherduck/agent-skills/). To install only this skill with the [Skills CLI](https://github.com/vercel-labs/skills), run:

```bash
npx -y skills add motherduckdb/agent-skills --skill motherduck-security-governance --yes --global
```

This skill relies on [`motherduck-connect`](/sql-reference/agent-skills/motherduck-connect/) and [`motherduck-explore`](/sql-reference/agent-skills/motherduck-explore/). Install those too, or install the full catalog.

:::

## Source of truth

- Prefer current MotherDuck public trust, security, pricing, and product documentation.
- If the MotherDuck MCP `ask_docs_question` feature is available, use it first.
- Use current SSO and data-recovery docs when the requirement involves identity-provider login, restore windows, named snapshots, or `UNDROP DATABASE`.
- Verify claims against live public materials before making compliance or commercial assertions.

## Default posture

- Prefer service accounts for production systems, not personal tokens.
- Enterprise organizations on SCIM can make the IdP the source of truth for user roles (Settings → Authentication): each sync sets a user's roles to exactly what the IdP sends, user roles can't be edited in MotherDuck, users with no role lose access, and service account roles stay in MotherDuck. Linked Enterprise organizations share one login, SSO connection, and SCIM provisioning while keeping separate members, data, and billing.
- Keep credentials in backend-controlled secrets, not browsers or hardcoded notebooks.
- Writes belong to the database owner; there is no write grant. Reads come from shares: restricted shares granted to roles, `INCLUDE_PATTERN` for which tables, secure views for which rows, columns, and values. Pick the archetype in [`references/ACCESS_CONTROL_SETUPS.md`](https://github.com/motherduckdb/agent-skills/blob/v3.4.0/skills/motherduck-security-governance/references/ACCESS_CONTROL_SETUPS.md) before writing grants.
- For answer or review requests, report the current and proposed access without changing it. For configure requests, apply the in-scope roles and grants, then verify them with `SHOW` statements and a real reader; ask before revoking access or widening an audience beyond the request.
- Prefer structural isolation over query-time tenant filtering for serious B2B or CFA workloads.
- Treat region and residency as first-class architectural constraints that require current public confirmation. MotherDuck runs on AWS and on Azure (`eastus`, `uksouth`); an organization's cloud and region are fixed at creation, shares don't cross regions, and `uksouth` keeps storage and processing in the UK for UK GDPR. Check `SELECT region FROM md_user_info()`.
- Be explicit about whether the boundary is a share, a Dive, a database, or a full application.
- Separate platform permissions (roles), data grants (who can attach a share), include patterns (which tables/views that share exposes), and secure views (which rows, columns, and values each consumer of that share sees).
- Secure views on shares provide row-level security, column-level security, and masking keyed on the consumer's identity, roles, or `session_context()` (plan-gated; verify current availability). With session context, trust follows whoever sets it: a token context minted server-side can't be changed by its holder, while a connection context is whatever the token holder chooses, so hand end users only token-context tokens and set every key the policy reads. For multi-tenant customer-facing products, structural isolation remains the stronger default; secure views fit internal audiences and partner or per-service-account shares.
- Dives have their own `READ` grant: new Dives are private, `GRANT READ ON DIVE` shares one with users, roles, or the organization, and `md_list_dive_grantees('<dive_id>'::UUID)` audits it. Opening a Dive grants nothing on its data or Flights; review the three together.
- Flight `RUN` grants let others trigger a Flight that always executes with the owner's credentials. Review them like any privileged entry point: who holds the grant, which config the caller controls, and what the owner's token can write.
- Map AI data flows explicitly: `prompt_jev()` sends text and images to TypeSafe in the US from every region (off by default in EU regions); `prompt()` from Asia Pacific regions is served by a US endpoint; Agent Chat inference stays in the organization's geography. Admins control these on the AI Features settings page.
- Flights can process PHI only under a signed HIPAA BAA; verify the current terms before relying on it.
- Separate documented product guarantees from architectural recommendations and assumptions in the final answer.

## Workflow

1. Identify where credentials live and who administers them.
2. Define the actual isolation boundary: account, database, schema, share secure view, or query filter.
3. Determine which preset/custom roles users hold, who can read, write, share, or administer the data, and which grants actually provide access.
4. Check whether residency, compliance, or contractual guarantees are part of the requirement.
5. Use only publicly documented security anchors unless the user has current commercial documentation in hand.

## References

Read only the reference sections needed for the current task.

- Read [`references/ACCESS_CONTROL_SETUPS.md`](https://github.com/motherduckdb/agent-skills/blob/v3.4.0/skills/motherduck-security-governance/references/ACCESS_CONTROL_SETUPS.md) to design or review who can read and write what: the access model, a requirement-to-mechanism table, seven setup archetypes (simple warehouse, dev/prod, curated BI reader, team roles, row- and column-level access, customer-facing hypertenancy, partners), Terraform, and verification.
- Read [`references/SECURITY_GOVERNANCE_PLAYBOOK.md`](https://github.com/motherduckdb/agent-skills/blob/v3.4.0/skills/motherduck-security-governance/references/SECURITY_GOVERNANCE_PLAYBOOK.md) for public security anchors, service-account posture, residency and AI data flows, sharing boundaries, Flight run grants, governance as code, and what not to overstate

## Related skills

Load related skills only for missing capabilities; reuse established context.

- [`motherduck-connect`](/sql-reference/agent-skills/motherduck-connect/) for secure token handling and endpoint selection
- [`motherduck-explore`](/sql-reference/agent-skills/motherduck-explore/) when governance depends on what data is actually present and how it is partitioned
- [`motherduck-share-data`](/sql-reference/agent-skills/motherduck-share-data/) when the design includes governed data distribution

## Files in this skill

The agent reads these files when the instructions above point to them.

- [`references/ACCESS_CONTROL_SETUPS.md`](https://github.com/motherduckdb/agent-skills/blob/v3.4.0/skills/motherduck-security-governance/references/ACCESS_CONTROL_SETUPS.md)
- [`references/SECURITY_GOVERNANCE_PLAYBOOK.md`](https://github.com/motherduckdb/agent-skills/blob/v3.4.0/skills/motherduck-security-governance/references/SECURITY_GOVERNANCE_PLAYBOOK.md)

## Docs this skill draws on

- [Service accounts](https://motherduck.com/docs/key-tasks/service-accounts-guide/)
- [Hypertenancy](https://motherduck.com/docs/concepts/compute/hypertenancy/)
- [Cloud regions](https://motherduck.com/docs/about-motherduck/cloud-regions/)
- [Sharing concepts and overview](https://motherduck.com/docs/key-tasks/sharing-data/sharing-overview/)
- [Sharing data in MotherDuck](https://motherduck.com/docs/key-tasks/sharing-data/)
- [Table-level security](https://motherduck.com/docs/key-tasks/sharing-data/table-level-security/)
- [Role-based access control (RBAC)](https://motherduck.com/docs/concepts/security-and-access/roles-and-access-control/)
- [Manage roles and access](https://motherduck.com/docs/key-tasks/managing-organizations/managing-roles/)
- [Setting up SSO](https://motherduck.com/docs/key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck/sso-setup/)
- [Data Recovery](https://motherduck.com/docs/concepts/database-and-storage/data-recovery/)
- [motherduck.com/trust-and-security](https://motherduck.com/trust-and-security/)
- [Row-level and column-level security with secure views](https://motherduck.com/docs/key-tasks/sharing-data/secure-views/)
- [Jev (TypeSafe)](https://motherduck.com/docs/integrations/data-science-ai/typesafe/)
- [Agent chat](https://motherduck.com/docs/key-tasks/ai-and-motherduck/ai-in-the-ui/agent-chat/)
- [GRANT RUN ON FLIGHT](https://motherduck.com/docs/sql-reference/motherduck-sql-reference/flights/grant-run-on-flight/)
- [Terraform](https://motherduck.com/docs/integrations/dev-tools/terraform/)
- [github.com/motherduckdb/terraform-provider-motherduck/tree/main/examples](https://github.com/motherduckdb/terraform-provider-motherduck/tree/main/examples)


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `GET https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

URL-encode query parameter values and send a GET request:

```text
GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fsql-reference%2Fagent-skills%2Fmotherduck-security-governance%2F&page_title=motherduck-security-governance&text=<url-encoded user feedback, max 2000 characters>
```

Optionally append `&source=<url-encoded interface identifier>` such as `claude.ai` or `chatgpt`.

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed query parameters, and `429` when rate-limited.
