RBAC Explained
Snowflake · Security & Governance
Theory
Snowflake combines role-based access control (RBAC) with discretionary access control (DAC). In RBAC, privileges such as SELECT on a table or USAGE on a warehouse are granted to roles, and roles are granted to users or to other roles. In DAC, every object has an owner role, and the owner can grant access to it. A user works under one active primary role at a time, and also gets privileges of roles below it in the hierarchy.
System roles form the top of the hierarchy: ACCOUNTADMIN contains SECURITYADMIN and SYSADMIN, SECURITYADMIN contains USERADMIN, and PUBLIC is granted to everyone. Best practice is to grant custom roles such as data_analyst to SYSADMIN, so administrators can manage the objects they create.
Why we use it
Granting privileges to roles instead of individual users makes access easy to audit and change. When someone joins or leaves a team you grant or revoke one role, instead of dozens of object grants.
When to use it
Use functional roles (analyst, engineer) that inherit access roles (read on a schema, write on a schema). Keep ACCOUNTADMIN for very few people with MFA, and use SYSADMIN or custom roles for daily work.
Roles, Not Users, Hold Privileges
Access is never granted straight to a user — privileges like SELECT on a table are granted to a role, and roles are granted to users, often through an inheritance hierarchy.
Built-In System Roles
SYSADMIN, SECURITYADMIN, and ACCOUNTADMIN cover common admin needs out of the box, each scoped to a different kind of administrative task.
Designing With Least Privilege
The model is built around giving each role only what it needs — a well-designed role hierarchy limits blast radius if any one set of credentials is compromised.
The Role Hierarchy
ACCOUNTADMIN ← top level (use sparingly) │ ┌─────────┼──────────┐ ▼ ▼ ▼ SYSADMIN SECURITYADMIN USERADMIN │ ▼ Custom Roles (data_engineer, data_analyst, ...) │ ▼ PUBLIC ← everyone has this role
How it works
- User runs a query
- Session has a primary role (and any secondary roles)
- Collect privileges from those roles and every role they inherit
- Is the needed privilege among them? Yes: Allow the action. No: Return an insufficient privileges error.
- Grant the right role, not a direct object privilege, to fix access
Example
CREATE ROLE data_engineer;
CREATE ROLE data_analyst;
CREATE ROLE data_scientist;
CREATE ROLE bi_viewer;
GRANT ROLE data_engineer TO ROLE sysadmin;
GRANT ROLE data_analyst TO ROLE sysadmin;
GRANT ROLE data_scientist TO ROLE data_analyst;
GRANT ROLE bi_viewer TO ROLE data_analyst;
GRANT USAGE ON DATABASE practice_db TO ROLE data_analyst;
GRANT SELECT ON ALL TABLES IN SCHEMA practice_db.learn TO ROLE data_analyst;
GRANT SELECT ON FUTURE TABLES IN SCHEMA practice_db.learn TO ROLE data_analyst;
GRANT USAGE ON WAREHOUSE analytics_wh TO ROLE data_analyst;
GRANT ROLE data_analyst TO USER john_smith;
SHOW GRANTS TO ROLE data_analyst;Key points
- Privileges go to roles; roles go to users or other roles
- Every object has an owner role that can grant access (DAC)
- Roles inherit privileges of roles granted to them
- Grant custom roles to SYSADMIN so admins can manage their objects
- Follow least privilege and keep ACCOUNTADMIN to a few users