What you will be able to do
- Assign and rotate RSA key pairs for service users without failed logins
- Generate programmatic access tokens and control their network, method, expiry and role requirements
- Set session policies for idle timeout and maximum lifespan, and monitor active sessions
- Explain what leaked password protection and malicious IP protection do automatically, and how an administrator responds
1.Key-pair authentication and rotation with no downtime
Service users cannot complete MFA, so they usually authenticate with a key pair. The minimum is a 2048-bit RSA pair generated with OpenSSL. The private key stays with the client in PKCS#8 PEM format. Encrypt it with AES-256-CBC where the client supports encrypted keys, and know that the passphrase never leaves the client. The public key is registered on the user. To do that, a role needs OWNERSHIP on the user or the MODIFY PROGRAMMATIC AUTHENTICATION METHODS privilege on it. Granting that privilege lets a service team manage its own keys without owning the user.
There are two ways to register the public key. The recommended one is a named key pair, ALTER USER ... ADD KEY PAIR my_key PUBLIC_KEY = '...', which supports role restriction and expiration. The older one sets the user's RSA_PUBLIC_KEY property, which supports neither. To confirm a key was registered correctly, compare RSA_PUBLIC_KEY_FP from DESC USER with the SHA-256 fingerprint OpenSSL computes for the local public key file. The fingerprint is something you read back from Snowflake, not something you set.
| Approach | Steps | How the overlap works |
|---|---|---|
| Named key pair (recommended) | ALTER USER ... ROTATE KEY PAIR my_key PUBLIC_KEY = '<new>', then move clients to the new private key | The previous key stays valid for 24 hours by default. EXPIRE_ROTATED_KEY_PAIR_AFTER_HOURS changes the grace period, and 0 expires it immediately |
| Two property slots | SET RSA_PUBLIC_KEY_2 to the new key, move clients to the new private key, then UNSET RSA_PUBLIC_KEY | Both keys are active together. Snowflake picks the matching public key from the private key each client presents |
The order of steps is what avoids downtime. If you overwrite RSA_PUBLIC_KEY in place, every client still using the old private key fails until it is redeployed. If you unset the old key before the new one is in use, you open the same gap. With the two-slot method, nothing expires on a timer. The old key stays valid until you unset it, so retire it only after the last client has moved.
Checkpoint 1 of 8· Put it in order
A service user authenticates with a key registered in RSA_PUBLIC_KEY, and several pipelines use it. Put the steps of a two-slot rotation with no downtime in order.
- 1.ALTER USER ... UNSET RSA_PUBLIC_KEY to retire the old key
- 2.Generate a new 2048-bit RSA key pair with OpenSSL
- 3.Update every client to connect with the new private key
- 4.ALTER USER ... SET RSA_PUBLIC_KEY_2 to the new public key
The new key goes into the free slot, so both keys are active and Snowflake matches each client's private key to the right public key. The old key has no 24-hour grace period here. It stays valid until you unset it, so you remove it only after the last client has moved.
“Set the public key value to either RSA_PUBLIC_KEY or RSA_PUBLIC_KEY_2, whichever key value is not currently in use.”Source: docs.snowflake.com
Checkpoint 2 of 8· Exam question
A data-ingestion service signs JWTs with an RSA key pair assigned to a TYPE = SERVICE user. Policy requires rotating the key with no failed logins. The current public key sits in RSA_PUBLIC_KEY. Which sequence achieves this?
Correct answer: B — Set the new public key in RSA_PUBLIC_KEY_2, move the service to the new private key, then run ALTER USER with UNSET RSA_PUBLIC_KEY to retire the old key.
- A. Incorrect: overwriting RSA_PUBLIC_KEY invalidates the old private key immediately, so the service fails until it is redeployed.
- B. Correct: a user can hold two public keys, so registering the new one in the free slot lets both private keys work during cutover; the old slot is then unset.
- C. Incorrect: the fingerprint is a read-only value derived from the registered key; it is not settable and creates no 24-hour grace period.
- D. Incorrect: unsetting the only key first leaves a window where no key authenticates, which is exactly the outage to avoid.
Sources1
2.Programmatic access tokens and the policy that governs them
A programmatic access token (PAT) is a bearer secret that works in two ways. It authenticates directly to the Snowflake REST and SQL APIs, Snowpark Container Services endpoints, and SCIM API requests. It can also replace a password in drivers, Snowflake CLI, SnowSQL and BI tools such as Tableau. PATs can be issued to human users (TYPE=PERSON) and to service users.
By default, PATs are tied to a network policy, and the exact rule depends on the user type. A SERVICE or LEGACY_SERVICE user can only generate or use a token while subject to a network policy, so a stolen token is useless from other addresses. A SERVICE_AGENT user has no such requirement. A PERSON user can generate a token without a network policy but needs one to authenticate with it. Network policies themselves are covered in network policies and rules. This behaviour is controlled by NETWORK_POLICY_EVALUATION in the PAT_POLICY clause of an authentication policy.
| Value | Network policy required to generate and use a PAT? | Is an existing network policy enforced? |
|---|---|---|
| ENFORCED_REQUIRED (default) | Yes | Yes |
| ENFORCED_NOT_REQUIRED | No | Yes |
| NOT_ENFORCED | No | No |
ALTER AUTHENTICATION POLICY my_authentication_policy
SET PAT_POLICY = (
NETWORK_POLICY_EVALUATION = NOT_ENFORCED
);Three more settings decide whether a token works. First, if an authentication policy limits AUTHENTICATION_METHODS, the list has to include 'PROGRAMMATIC_ACCESS_TOKEN'. A policy allowing only ('OAUTH', 'PASSWORD') blocks PATs silently. Second, tokens expire after 15 days by default, and users can request up to 365. DEFAULT_EXPIRY_IN_DAYS and MAX_EXPIRY_IN_DAYS change those limits. If you lower the maximum, existing tokens whose lifetime exceeds the new value stop authenticating, so check what is in use before you shorten it. Third, a token for a service user must name the role its sessions will run as. REQUIRE_ROLE_RESTRICTION_FOR_SERVICE_USERS = FALSE lifts that requirement, and setting it back to TRUE invalidates the tokens that were generated without a role.
Checkpoint 3 of 8· Check yourself
Your contractors use PATs from changing home networks. Security wants a user who has no network policy to still be able to generate and use a PAT. Any user who does have a network policy must still be held to it. Which NETWORK_POLICY_EVALUATION value do you set in PAT_POLICY?
ENFORCED_NOT_REQUIRED removes the requirement to have a network policy, but any network policy that applies is still enforced. NOT_ENFORCED would also stop enforcing existing policies. ENFORCED_REQUIRED is the default, and it still requires a network policy.
“to create an authentication policy that removes the network policy requirement but enforces any network policy that the user is subject to”Source: docs.snowflake.com
Checkpoint 4 of 8· Check yourself
Troubleshooting: a pipeline's service user is subject to a network policy and holds a PAT that names its role. The PAT still cannot authenticate. The account's authentication policy has AUTHENTICATION_METHODS = ('OAUTH', 'PASSWORD'). What fixes it?
When a policy limits AUTHENTICATION_METHODS, PATs work only if the list includes 'PROGRAMMATIC_ACCESS_TOKEN'. The network policy and the role restriction are already satisfied, so changing them does not help.
“the user cannot generate and use programmatic access tokens unless the AUTHENTICATION_METHODS list in that policy includes 'PROGRAMMATIC_ACCESS_TOKEN'”Source: docs.snowflake.com
Sources2
3.Session policies: idle timeout, lifespan and monitoring
A session policy decides how long an authenticated session lasts before the user has to sign in again. It has separate settings for Snowsight and for programmatic or client sessions, because the two are used very differently. The idle timer starts at successful authentication. Without a policy, client sessions time out after 240 idle minutes and Snowsight sessions after 1080. Idle timeout alone never ends a session that stays busy. To force reauthentication after a fixed period regardless of activity, set a maximum lifespan.
| Property | Applies to | Range | Default |
|---|---|---|---|
| SESSION_IDLE_TIMEOUT_MINS | Snowflake and programmatic clients | 5–1440 | 240 |
| SESSION_UI_IDLE_TIMEOUT_MINS | Snowsight | 5–1440 | 1080 |
| SESSION_MAX_LIFESPAN_MINS | Snowflake and programmatic clients | 0–43200 | 0 (no maximum) |
| SESSION_UI_MAX_LIFESPAN_MINS | Snowsight | 0–43200 | 0 (no maximum) |
You attach a session policy with ALTER ACCOUNT SET SESSION POLICY or ALTER USER jsmith SET SESSION POLICY. A policy on the user overrides the one on the account. To swap in a different policy, unset the current one first and then set the new one. Setting the policy needs APPLY SESSION POLICY on the account or user, and changing it needs OWNERSHIP of the policy. The same object can also carry ALLOWED_SECONDARY_ROLES. Setting it to () makes any USE SECONDARY ROLES command fail for the affected users. Secondary roles themselves are covered in role hierarchy and secondary roles.
Session monitoring uses two places. Query SNOWFLAKE.ACCOUNT_USAGE.SESSIONS to see sessions across the account. In Snowsight, the Sessions tab under Governance & security » Network policies lists each session's user, start time, client driver, client address and authentication method. To check which users a policy is attached to, use POLICY_REFERENCES.
Checkpoint 5 of 8· Check yourself
A reporting client sets CLIENT_SESSION_KEEP_ALIVE to TRUE and queries constantly. Its session policy has SESSION_IDLE_TIMEOUT_MINS = 30 and SESSION_MAX_LIFESPAN_MINS = 480. What happens after eight hours?
Idle timeout only measures inactivity, and keep-alive preserves the session against it. The maximum lifespan is a hard cap, so the session ends when it is reached however busy it is.
“the session still ends when that lifespan is reached, regardless of activity”Source: docs.snowflake.com
4.Leaked password protection
Leaked password protection runs in the background. It is on by default and cannot be turned off. When Snowflake finds a leaked password, it first checks whether the password still authenticates. If it does, Snowflake unsets the password and will not accept that password from that user in the future. The user object is not disabled, so SSO and other methods keep working. The user does not get a chance to keep the old password until a later change. It stops working immediately. Every user type is scanned, so a service user that still has a password is affected as well.
Snowflake sends email to the user and the administrators. Administrator notices go to the verified account-level security contacts if there are any, otherwise to organization-level contacts, and otherwise to users with admin roles. When the affected user next tries to sign in, a message tells them to ask an administrator for a reset link. The new password has to meet the account's password policy. If the leaked password belongs to an administrator and no other administrator can reset it, contact Snowflake Support.
Checkpoint 6 of 8· Check yourself
Leaked password protection has just unset the password of a nightly pipeline's service user, which was still signing in with a password. What is the right long-term fix for that user?
Only the password is unset, and service users cannot complete MFA, so they should not rely on a password at all. Moving the user to key-pair authentication (or a token) removes the leaked credential for good, and leaked password protection cannot be turned off anyway.
“MFA is intended for human users who authenticate with a password. Service users must use another form of authentication.”Source: docs.snowflake.com
Checkpoint 7 of 8· Exam question
A security researcher publishes a breach dump, and Snowflake's leaked password protection matches the current password of a PERSON user in your account. What does Snowflake do on its own?
Correct answer: C — It confirms the password still works, unsets it so password sign-in stops, and emails the affected user and account administrators.
- A. Incorrect: Snowflake does not create or attach authentication policies for this feature; the protection works by unsetting the password itself.
- B. Incorrect: Snowflake does not disable the user or kill sessions; only the password is removed, so SSO or key-pair sign-in continues to work.
- C. Correct: the service verifies the password still authenticates, then unsets it and notifies contacts; the user can still use other methods such as SSO and is told to request a reset link.
- D. Incorrect: the leaked password is not left usable. It is unset immediately, rather than forcing a change at next login.
Sources5
5.Malicious IP protection
Malicious IP protection blocks network access attempts from addresses on a list that Snowflake curates from third-party threat intelligence. It covers IPv4 and IPv6. Blocking applies to all four categories by default, so there is no parameter to switch it on: ANONYMOUS_VPN, ANONYMOUS_PROXIES, MALICIOUS_BEHAVIOR (such as automated brute-force attempts) and TOR_EXITS.
Blocked attempts appear in the Account Usage LOGIN_HISTORY view. Their is_success value is NO, and their login_details contains malicious_ip_protection_info with a result of BLOCKED, a riskClassification of LOW or HIGH, and the matched categories. The source address is in the ip_address column.
SELECT *
FROM SNOWFLAKE.ACCOUNT_USAGE.LOGIN_HISTORY
WHERE NOT is_success AND login_details IS NOT NULL
ORDER BY event_timestamp DESC;If legitimate users are being blocked, you can relax the protection by category with SYSTEM$OPT_OUT_MALICIOUS_IP_PROTECTION_BY_CATEGORY. Only ACCOUNTADMIN can call it. Opting out works for low-risk classifications only, and high-risk ones stay blocked. An optional second argument limits the opt-out to one user, such as a contractor's account. Each call replaces the previous one. To opt out of two categories, pass both in a single string, as in 'ANONYMOUS_VPN,MALICIOUS_BEHAVIOR'. Passing '' restores blocking for everything. Attempts that are let through by an opt-out are recorded with a result of OPTED_OUT. Because of the overwrite behaviour, a later call that names only one category quietly re-enables blocking for any category it leaves out.
Checkpoint 8 of 8· Exam question
Your SOC wants evidence that Snowflake's malicious IP protection is blocking sign-in attempts from anonymizing infrastructure. You also want to relax blocking for one low-risk category used by contractors. Which statements are accurate? (Select all that apply.)(Select 3)
Correct answers: A, B, E — SYSTEM$OPT_OUT_MALICIOUS_IP_PROTECTION_BY_CATEGORY can exclude low-risk categories from blocking, while high-risk categories stay blocked.; Blocking is driven by a curated threat-intelligence list, so it is enabled by default and covers categories such as TOR exit nodes and anonymous proxies.; Blocked attempts show up in ACCOUNT_USAGE.LOGIN_HISTORY with IS_SUCCESS = NO and LOGIN_DETAILS carrying a BLOCKED result plus the risk class and IP categories.
- A. Correct: the opt-out function applies to low-risk categories only; high-risk categories remain blocked.
- B. Correct: Snowflake maintains a curated list (anonymous VPNs, proxies, malicious behavior, TOR exits) and blocks matches by default.
- C. Incorrect: no account parameter turns this on. It is enabled by default and independent of network policies.
- D. Incorrect: a network policy allowlist is a separate control and does not exempt an address from the curated-list blocking.
- E. Correct: blocked attempts are recorded in LOGIN_HISTORY, with details showing the BLOCKED result and category information.
Practise it for real
Harden a session and audit the automatic threat protections in a test account
1.As a role with CREATE SESSION POLICY and APPLY SESSION POLICY, create a session policy with SESSION_IDLE_TIMEOUT_MINS = 30 and SESSION_MAX_LIFESPAN_MINS = 480, then run ALTER USER with your test user's name and SET SESSION POLICY naming the new policy.
Why: A policy on the user overrides any policy on the account, so you can test on one user without affecting others.
You should see: POLICY_REFERENCES for the policy returns a row for the test user.
2.Query SNOWFLAKE.ACCOUNT_USAGE.SESSIONS for the test user.
Why: This is the SQL way to monitor sessions, alongside the Sessions tab in Snowsight.
You should see: Rows for the user's sessions, each showing the authentication method used.
3.Run the LOGIN_HISTORY query filtered on NOT is_success AND login_details IS NOT NULL.
Why: Malicious IP blocks are recorded as failed logins with details attached.
You should see: Any blocked attempts show malicious_ip_protection_info with result BLOCKED and a riskClassification.
4.As ACCOUNTADMIN, call SYSTEM$OPT_OUT_MALICIOUS_IP_PROTECTION_BY_CATEGORY('MALICIOUS_BEHAVIOR', 'TEST_USER') with your test user's name in place of TEST_USER, then call it again with '' and the same user.
Why: This shows a user-scoped opt-out and how a later call overwrites the earlier one.
You should see: Each call returns a status message. After the second call, blocking is back in place for that user.
Stuck? Get a nudge
If an opt-out seems to have disappeared, check whether a later call to the function overwrote it.
Sources
(8)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“This authentication method requires, as a minimum, a 2048-bit RSA key pair.”
↩︎ Key-pair authentication and rotation with no downtime“This approach does not support role restriction or expiration.”
↩︎ Key-pair authentication and rotation with no downtime“By default, the prior key remains valid for 24 hours.”
↩︎ Key-pair authentication and rotation with no downtime“Snowflake verifies the correct active public key for authentication based on the private key submitted with your connection information.”
↩︎ Exam trap 1“Set the public key value to either RSA_PUBLIC_KEY or RSA_PUBLIC_KEY_2, whichever key value is not currently in use.”
↩︎ Checkpoint - 2.
“you can only generate or use a token if the user is subject to a network policy.”
↩︎ Programmatic access tokens and the policy that governs them“By default, a programmatic access token expires after 15 days.”
↩︎ Programmatic access tokens and the policy that governs them“you must specify the role that will be used during sessions authenticated with that token.”
↩︎ Programmatic access tokens and the policy that governs them“to create an authentication policy that removes the network policy requirement but enforces any network policy that the user is subject to”
↩︎ Checkpoint“the user cannot generate and use programmatic access tokens unless the AUTHENTICATION_METHODS list in that policy includes 'PROGRAMMATIC_ACCESS_TOKEN'”
↩︎ Checkpoint - 3.
“If a user is associated with both an account and user-level session policy, the user-level session policy takes precedence.”
↩︎ Session policies: idle timeout, lifespan and monitoring“Query the SESSIONS view in the ACCOUNT USAGE schema of the shared SNOWFLAKE database to monitor session usage.”
↩︎ Session policies: idle timeout, lifespan and monitoring“the session still ends when that lifespan is reached, regardless of activity”
↩︎ Checkpoint - 4.
“unset the session policy first and then set the new session policy for the account or user.”
↩︎ Session policies: idle timeout, lifespan and monitoring - 5.
“Leaked password protection is enabled by default, and you cannot disable leaked password protection.”
↩︎ Leaked password protection“Snowflake then notifies the administrator and user about the leaked password through email.”
↩︎ Leaked password protection“the user cannot authenticate using their password, but the user can use other methods of authentication, such as SSO, if available.”
↩︎ Exam trap 2“Snowflake disables the leaked password by unsetting the password for the user”
↩︎ Prediction - 6.
“NO appears in the is_success column for blocked network access attempts.”
↩︎ Malicious IP protection“You can manage Malicious IP Protection by opting out of blocking IP addresses that are categorized as low-risk.”
↩︎ Malicious IP protection“blocks network access attempts that originate from IP addresses in all categories on this curated list by default.”
↩︎ Exam trap 3 - 7.https://docs.snowflake.com/en/sql-reference/functions/system_opt_out_malicious_ip_protection_by_categoryOfficial docs
“Each call of this function overwrites results of the previous call.”
↩︎ Malicious IP protection
Also cited
“MFA is intended for human users who authenticate with a password. Service users must use another form of authentication.”
↩︎ Checkpoint