What you will be able to do
- Set up a service account with a dedicated least-privilege role and a non-interactive authentication method
- Choose between a named key pair, a PAT and External OAuth for an automated integration, and rotate keys without downtime
- Block ad hoc unloads and credential-based stages with the account-level exfiltration parameters
- Apply account-wide limits on who can use Cortex AI functions and where inference may run
1.Service accounts for automated integrations
Pipelines, connectors and IdPs need a login with no human behind it. The pattern has three parts. Create a user of type SERVICE (see User types: PERSON, SERVICE and NULL). Give it its own role, holding only the privileges the integration needs, and make that role its default. Then authenticate it with something non-interactive: a key pair, a programmatic access token (PAT) or OAuth. Snowflake's own setup for a SCIM IdP's service user follows this pattern. The dedicated role is later granted USAGE on just the one integration.
CREATE ROLE scim_role;
GRANT ROLE scim_role TO USER scim_idp_user;
ALTER USER scim_idp_user SET DEFAULT_ROLE = scim_role;The role restriction goes on the credential as well as the user. When a PAT is generated for a service user, ROLE_RESTRICTION names the role the token may use. A leaked token then can't do anything beyond that one role's privileges.
ALTER USER IF EXISTS scim_idp_user
ADD PROGRAMMATIC ACCESS TOKEN scim_pat_token
ROLE_RESTRICTION = 'scim_role';Which credential to choose depends on who issues it. External OAuth wins when an authorization server the company already runs can issue tokens to the client. Snowflake then only validates the tokens and stores no secret for that client. A PAT suits a client that can only send a bearer token. Key-pair authentication suits a client that runs on a Snowflake driver or connector, which covers the CLI, SnowSQL, JDBC, ODBC, Python, Spark and Kafka. The private key never leaves the client. Its passphrase isn't sent to Snowflake either. Snowflake stores only the public key.
Checkpoint 1 of 4· Check yourself
A nightly load job runs on the Snowflake Connector for Python and logs in as a dedicated SERVICE user with its own role. The company has no authorization server that could issue tokens to the job. Which setup fits the guidance for this client?
The job runs on a Snowflake connector, so key-pair authentication is the right choice. The public key is registered on the service user, and the private key and its passphrase never leave the client. External OAuth needs a third-party authorization server that issues the tokens, with Snowflake only checking them.
“The public key is assigned to the Snowflake user who uses the Snowflake client to connect and authenticate to Snowflake.”Source: docs.snowflake.com
2.Key pairs for pipelines: registering and rotating
For key pairs, the important decision is how the public key is stored. A key pair needs at least a 2048-bit RSA key. Key-pair authentication and rotation covers generating the keys. For a service account, use a named key pair, registered with ALTER USER … ADD KEY PAIR. Named key pairs support role restriction and expiry. The older RSA_PUBLIC_KEY property supports neither. To let a team manage a service user's keys without owning the user, grant their role MODIFY PROGRAMMATIC AUTHENTICATION METHODS on that user.
ALTER USER example_user ADD KEY PAIR my_key
PUBLIC_KEY = 'MIIBIjANBgkqh...';| Aspect | Named key pair | RSA_PUBLIC_KEY / RSA_PUBLIC_KEY_2 |
|---|---|---|
| Register | ALTER USER … ADD KEY PAIR | ALTER USER … SET RSA_PUBLIC_KEY |
| Role restriction and expiration | Supported | Not supported |
| Rotation | ROTATE KEY PAIR; old key kept for a grace period (EXPIRE_ROTATED_KEY_PAIR_AFTER_HOURS) | Set the unused slot, switch clients over, then UNSET the old slot |
| Inspect | SHOW USER KEY PAIRS | DESC USER (RSA_PUBLIC_KEY_FP) |
Checkpoint 2 of 4· Fill the gap
A pipeline's SERVICE user needs a public key that can later be given a role restriction and an expiration. Which keyword completes the statement that registers it?
ALTER USER example_user ? KEY PAIR my_key
PUBLIC_KEY = 'MIIBIjANBgkqh...';ADD KEY PAIR registers a new named key pair, and only named key pairs support role restriction and expiration. ROTATE KEY PAIR replaces the key on a named pair that already exists, and REMOVE KEY PAIR deletes one. SET is the older RSA_PUBLIC_KEY approach, which supports neither role restriction nor expiration.
Source: docs.snowflake.comSources2
3.Blocking data exfiltration with account parameters
A user with SELECT on a table and permission to run COPY INTO can try to unload the table to any cloud bucket they control. Snowflake closes this route with account parameters. PREVENT_UNLOAD_TO_INLINE_URL blocks ad hoc unloads to an external location typed directly into the COPY statement. Two REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_* parameters make sure that the stages that remain go through a storage integration. A storage integration is an object an administrator controls. A key someone pasted into a statement is not.
| Parameter | When TRUE | Default |
|---|---|---|
| PREVENT_UNLOAD_TO_INLINE_URL | Blocks ad hoc unloads to an external URL given inline in COPY INTO <location> | — |
| REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION | CREATE STAGE for a private cloud storage location must reference a storage integration instead of explicit credentials | FALSE |
| REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION | Loading from or unloading to private cloud storage must use a named stage that references a storage integration; a stage holding secret keys or access tokens raises an error | FALSE |
The two storage-integration parameters cover different times, so set both. ..._CREATION only stops new stages that embed credentials. Stages created before you turned it on still work. ..._OPERATION blocks every load or unload through a credential-based stage, whatever its age. These parameters can be set only at the account level, with ALTER ACCOUNT SET REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION = TRUE and the matching statements for the other two. A user or session can't override them.
Checkpoint 3 of 4· Check yourself
Last quarter an admin set REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION to TRUE. An older external stage, created earlier with an AWS secret key, is still used by a nightly COPY job. Security wants that job to fail with an error. What should they do?
The creation parameter only governs new CREATE STAGE statements, so the older stage keeps working. The operation parameter is the one that makes loads and unloads through a credential-based stage fail. PREVENT_UNLOAD_TO_INLINE_URL only covers ad hoc unloads with the URL typed into the COPY statement, and these parameters can't be set at session level.
“specifying a named external stage that references explicit cloud provider credentials, such as secret keys or access tokens, produces a user error.”Source: docs.snowflake.com
4.Account-wide limits on AI features and models
Every user can use Cortex AI functions by default. Calling a Cortex function requires two things: the USE AI FUNCTIONS account privilege and the SNOWFLAKE.CORTEX_USER database role. Both are granted to PUBLIC out of the box. Per-role and per-function grants are covered in Access control for Cortex AI functions and models. At the account level, turning AI off for everyone except approved roles means revoking both grants from PUBLIC as ACCOUNTADMIN, the only role that can manage this privilege.
REVOKE DATABASE ROLE SNOWFLAKE.CORTEX_USER
FROM ROLE PUBLIC;
REVOKE IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE
FROM ROLE PUBLIC;These defaults have some uneven edges:
- The narrower
AI_FUNCTIONS_USERrole is not granted to PUBLIC. - Neither database role can be granted to a user directly, only to a role.
USE AI FUNCTIONSdoes not apply inside Snowflake native applications. AI calls there succeed whether or not the role holds it.
Data residency is a separate account setting. CORTEX_ENABLED_CROSS_REGION accepts 'DISABLED', 'ANY_REGION' or a list of regions. It controls whether Cortex inference may run outside the account's own region, and if so in which regions. A governance rule that says "no inference outside our region" is enforced by setting it to 'DISABLED' with ALTER ACCOUNT. Revoking privileges from roles does not enforce it.
Checkpoint 4 of 4· Check yourself
Governance has decided that only the DATA_SCIENCE role may call Cortex AI functions. Nothing about AI access has been changed in the account yet. Which approach meets the requirement?
USE AI FUNCTIONS and CORTEX_USER are both granted to PUBLIC by default, so everyone can call Cortex until ACCOUNTADMIN revokes both from PUBLIC and grants them to the approved role. Granting something extra to DATA_SCIENCE leaves PUBLIC's defaults in place. CORTEX_USER can't be granted to a user directly. CORTEX_ENABLED_CROSS_REGION controls where inference runs, not who can use it.
“If you don’t want all your users to have this privilege, you can revoke access to the PUBLIC role and grant access to other roles.”Source: docs.snowflake.com
Sources
(6)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“When generating the PAT, you must set the ROLE_RESTRICTION parameter to the name of the role that you created for the service user.”
↩︎ Service accounts for automated integrations“GRANT USAGE ON INTEGRATION okta_provisioning TO ROLE scim_role;”
↩︎ Service accounts for automated integrations - 2.
“The passphrase is only used for protecting the private key and will never be sent to Snowflake.”
↩︎ Service accounts for automated integrations“This authentication method requires, as a minimum, a 2048-bit RSA key pair.”
↩︎ Key pairs for pipelines: registering and rotating“Snowflake recommends registering a named key pair with ALTER USER … ADD KEY PAIR, which supports role restriction, named key management, and key expiration.”
↩︎ Key pairs for pipelines: registering and rotating“MODIFY PROGRAMMATIC AUTHENTICATION METHODS privilege on the user.”
↩︎ Key pairs for pipelines: registering and rotating“This approach does not support role restriction or expiration.”
↩︎ Exam trap 2“The public key is assigned to the Snowflake user who uses the Snowflake client to connect and authenticate to Snowflake.”
↩︎ Checkpoint“By default, the prior key remains valid for 24 hours.”
↩︎ Prediction - 3.
“Snowflake provides a set of parameters to further restrict data unloading operations: PREVENT_UNLOAD_TO_INLINE_URL prevents ad hoc data unload”
↩︎ Blocking data exfiltration with account parameters - 4.
“require a storage integration object as cloud credentials when creating a named external stage”
↩︎ Blocking data exfiltration with account parameters“Account — Can be set only for Account”
↩︎ Blocking data exfiltration with account parameters“specifying a named external stage that references explicit cloud provider credentials, such as secret keys or access tokens, produces a user error.”
↩︎ Exam trap 1“specifying a named external stage that references explicit cloud provider credentials, such as secret keys or access tokens, produces a user error.”
↩︎ Checkpoint - 5.
“By default, the USE AI FUNCTIONS privilege is granted to the PUBLIC role.”
↩︎ Account-wide limits on AI features and models“You must use the ACCOUNTADMIN role to manage the USE AI FUNCTIONS account-level privilege.”
↩︎ Account-wide limits on AI features and models“The SNOWFLAKE.CORTEX_USER database role cannot be granted directly to a user.”
↩︎ Account-wide limits on AI features and models“Currently, USE AI FUNCTIONS does not apply to AI Function queries that are run inside Snowflake native applications.”
↩︎ Account-wide limits on AI features and models“If you don’t want all your users to have this privilege, you can revoke access to the PUBLIC role and grant access to other roles.”
↩︎ Checkpoint - 6.
“CORTEX_ENABLED_CROSS_REGION = { 'DISABLED' | 'ANY_REGION' | '<list_of_regions>' }”
↩︎ Account-wide limits on AI features and models