Snowflake Gen AI Governance · Topic 2 of 15

Application Roles and RBAC for Model Access

Use SNOWFLAKE.MODELS objects and CORTEX-MODEL-ROLE application roles to give each role specific Cortex models and migrate off the allowlist.

  • 5 min
In a nutshell
  • Model objects live in SNOWFLAKE.MODELS; the roles are CORTEX-MODEL-ROLE-<MODEL> and CORTEX-MODEL-ROLE-ALL.
  • They are granted with GRANT APPLICATION ROLE SNOWFLAKE."...".
  • A daily task, CORTEX_BASE_MODELS_REFRESH_TASK, keeps them current.

What it is

RBAC for model access treats each Cortex model as an object you can grant. Snowflake keeps these model objects in the SNOWFLAKE.MODELS schema. For each model there is a matching application role that you grant to your own custom roles.

An application role is a role that belongs to an application, here the SNOWFLAKE application. You grant it to account roles with GRANT APPLICATION ROLE, much like a database role.

SNOWFLAKE.MODELSmodel objectsdaily refresh createsApplication rolesone per model plus ALLgranted toCustom roleanalyst_roleheld byUsers

How it works

Model objects and per-model roles

A daily refresh fills SNOWFLAKE.MODELS with objects that represent the Cortex base models and creates the matching application roles. The naming pattern is CORTEX-MODEL-ROLE-<MODEL>, for example CORTEX-MODEL-ROLE-LLAMA3.1-70B. The special role CORTEX-MODEL-ROLE-ALL covers all current and future models.

Because the names contain hyphens and dots, you must put them in double quotes.

GRANT APPLICATION ROLE SNOWFLAKE."CORTEX-MODEL-ROLE-LLAMA3.1-70B" TO ROLE analyst_role;
GRANT APPLICATION ROLE SNOWFLAKE."CORTEX-MODEL-ROLE-ALL" TO ROLE data_science_role;

Refreshing the list

The refresh runs as the Snowflake-managed task SNOWFLAKE.MODELS.CORTEX_BASE_MODELS_REFRESH_TASK. When a new model appears and you cannot wait, ACCOUNTADMIN can run it on demand.

CALL SNOWFLAKE.MODELS.CORTEX_BASE_MODELS_REFRESH();
SHOW MODELS IN SNOWFLAKE.MODELS;
SHOW APPLICATION ROLES LIKE 'CORTEX-MODEL%' IN APPLICATION SNOWFLAKE;

Calling a model under RBAC

You pass the model object identifier to a supported function. An unqualified name resolves to SNOWFLAKE.MODELS, so both calls below point at the same model.

SELECT AI_COMPLETE('SNOWFLAKE.MODELS."LLAMA3.1-70B"', 'Hello');
SELECT AI_COMPLETE('llama3.1-70b', 'Hello');

The bootstrap grant to PUBLIC

New accounts start with the allowlist at 'All'. To keep that behavior under RBAC, CORTEX-MODEL-ROLE-ALL is granted to the SNOWFLAKE.PUBLIC application role, which reaches the account PUBLIC role. Every user therefore has every model until you remove that grant.

A plain REVOKE does not remove it. Use the Snowflake-provided stored procedures, which need the SNOWFLAKE_PUBLIC_GRANT_ADMIN application role (ACCOUNTADMIN has it).

CALL SNOWFLAKE.LOCAL.REVOKE_FROM_PUBLIC_APPLICATION_ROLE('APP_ROLE', 'CORTEX-MODEL-ROLE-ALL');
CALL SNOWFLAKE.LOCAL.GRANT_TO_PUBLIC_APPLICATION_ROLE('APP_ROLE', 'CORTEX-MODEL-ROLE-ALL');

Migrating from the allowlist to RBAC

Snowflake recommends RBAC and setting the allowlist to 'None' so that RBAC is the only mechanism. The documented steps are:

  1. Check the current value with SHOW PARAMETERS LIKE 'CORTEX_MODELS_ALLOWLIST' IN ACCOUNT;.
  2. Grant equivalent model roles to PUBLIC, or grant CORTEX-MODEL-ROLE-ALL, so nobody loses access.
  3. Test with a non-ACCOUNTADMIN role.
  4. Set the allowlist to 'None'.
Check valueSHOW PARAMETERSthenGrant model rolesequal to old listthenTestnon ACCOUNTADMIN rolethenSet allowlistto None

Allowlist versus RBAC

PointAllowlistRBAC
GranularityWhole accountPer role and per model
Set withALTER ACCOUNTGRANT APPLICATION ROLE
Who sets itACCOUNTADMINA role that can grant the application role
StatusLegacy, being removedRecommended
Exam tip

To let only one team use an expensive model, remove the bootstrap grant of the ALL role from PUBLIC, grant the single model role to that team's role, and set the allowlist to 'None'.

Application roles compared with other role types

The exam may ask you to tell the role types apart. All three can be granted to account roles, but they come from different places.

Role typeBelongs toExampleGrant statement
Account roleThe accountanalyst_roleGRANT ROLE
Database roleA databaseSNOWFLAKE.CORTEX_USERGRANT DATABASE ROLE
Application roleAn applicationSNOWFLAKE."CORTEX-MODEL-ROLE-ALL"GRANT APPLICATION ROLE

Model access is controlled with application roles, while feature access (CORTEX_USER and similar) is controlled with database roles. A role needs both layers: the database role opens the feature and the application role opens the model.

A design example

A company wants analysts to use one small model, data scientists to use every model, and nobody else to use any. A clean design is:

  1. Call REVOKE_FROM_PUBLIC_APPLICATION_ROLE for the ALL role so PUBLIC no longer has every model.
  2. Grant the single small model role to analyst_role.
  3. Grant CORTEX-MODEL-ROLE-ALL to data_science_role.
  4. Set the allowlist to 'None', so RBAC alone decides.
  5. Test with a normal user and USE SECONDARY ROLES NONE.

Because future models are covered by the ALL role, data scientists see new models after the next refresh without another grant. Analysts do not, which is the intended behavior.

Common mistakes

Using plain REVOKE on the PUBLIC bootstrap grant. It has no effect. Call SNOWFLAKE.LOCAL.REVOKE_FROM_PUBLIC_APPLICATION_ROLE.

Forgetting the quotes. SNOWFLAKE.CORTEX-MODEL-ROLE-ALL without double quotes fails because of the hyphens.

Setting the allowlist to 'None' before granting roles. Users who relied on the allowlist lose access at once.

Granting GRANT DATABASE ROLE for model roles. Model roles are application roles, so the statement is GRANT APPLICATION ROLE.

Expecting a brand new model to appear instantly. The list refreshes daily; run the refresh procedure if you need it sooner.

What to remember for the exam

  • Model objects live in SNOWFLAKE.MODELS; the roles are CORTEX-MODEL-ROLE-<MODEL> and CORTEX-MODEL-ROLE-ALL.
  • They are granted with GRANT APPLICATION ROLE SNOWFLAKE."...".
  • A daily task, CORTEX_BASE_MODELS_REFRESH_TASK, keeps them current.
  • The ALL role is granted to PUBLIC at the start; remove it with REVOKE_FROM_PUBLIC_APPLICATION_ROLE.
  • Snowflake recommends RBAC with the allowlist set to 'None'.

Check yourself

  • Which statement gives a role access to one Cortex model?

    GRANT APPLICATION ROLE SNOWFLAKE."CORTEX-MODEL-ROLE-<MODEL>" TO ROLE, using double quotes around the role name.

  • How do you remove the default access that PUBLIC has to all models?

    Call SNOWFLAKE.LOCAL.REVOKE_FROM_PUBLIC_APPLICATION_ROLE for CORTEX-MODEL-ROLE-ALL, because a raw REVOKE does not remove it.

  • What is the recommended order when moving from the allowlist to RBAC?

    Check the current value, grant equivalent model roles, test with a normal role, then set the allowlist to 'None'.

Topic 2 of 15 in Snowflake Gen AI Governance

Test yourself on Snowflake Gen AI Governance

The full Snowflake GES-C02 question bank has 585 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.