Course contents

SnowPro Core COF-C03 Study GuidePart 3: Access control and securityNetwork Policies

Network Policies

Network Policies

In short

A network policy decides whether a connection from an address may exist. It knows nothing about rows, columns or roles.

The problem

A stolen password or key should be useless from an attacker's laptop. A network policy makes that true by limiting which network addresses can connect to Snowflake.

The mental model

The current design splits addresses from policy. A network rule is a schema-level object that holds a list of identifiers of one type. Most often that is IPv4 ranges. It can also be private-endpoint IDs, used when a company reaches Snowflake through its cloud provider's private network instead of the public internet. A network policy lists rules in an allowed list and a blocked list. The policy itself is an account-level object, so its name has no database or schema. It is attached to the account, a user, or a security integration (SCIM, Snowflake OAuth and External OAuth integrations accept one). Change one rule and every policy that lists it picks up the change.

IPv4 ranges use CIDR notation: the number after the slash says how many leading bits are fixed. So /32 is exactly one address, /28 is 16 addresses and /24 is 256. The rules below use documentation addresses, so the numbers are illustrative.

Network rules hold addresses. A network policy lists rules in its allowed list or its blocked list, and is attached at one of three levels. Rows are ordered by precedence. 1: TABLEAU_POLICY on the security integration TABLEAU_OAUTH, the most specific. 2: ETL_ONLY on the service user SVC_ETL. 3: CORP_POLICY on the account, for everyone else; it allows PARIS_OFFICE and VPN_EXIT and blocks BAD_HOST.NETWORK RULES · ADDRESSESNETWORK POLICIESATTACHED TO · PRECEDENCERULETABLEAU_RANGETableau Cloud addressesRULEETL_SERVER192.0.2.7/32 (1 address)RULEPARIS_OFFICE203.0.113.0/24RULEVPN_EXIT198.51.100.0/28RULEBAD_HOST203.0.113.99/32TABLEAU_POLICYallowed: TABLEAU_RANGEETL_ONLYallowed: ETL_SERVERCORP_POLICYallowed: PARIS_OFFICE,VPN_EXITblocked: BAD_HOST1 · SECURITY INTEGRATIONTABLEAU_OAUTHmost specific2 · USERUser SVC_ETLoverrides the account3 · ACCOUNTAccounteveryone elseattached toattached toattached to

NETWORK RULES · ADDRESSES

RULETABLEAU_RANGETableau Cloud addresses

NETWORK POLICIES

TABLEAU_POLICYallowed: TABLEAU_RANGE

attached to

ATTACHED TO · PRECEDENCE

1 · SECURITY INTEGRATIONTABLEAU_OAUTHmost specific

RULEETL_SERVER192.0.2.7/32 (1 address)

ETL_ONLYallowed: ETL_SERVER

attached to

2 · USERUser SVC_ETLoverrides the account

  • RULEPARIS_OFFICE203.0.113.0/24

  • RULEVPN_EXIT198.51.100.0/28

  • RULEBAD_HOST203.0.113.99/32

CORP_POLICYallowed: PARIS_OFFICE, VPN_EXITblocked: BAD_HOST

attached to

3 · ACCOUNTAccounteveryone else

Figure 3.12 Rules hold addresses, policies list rules as allowed or blocked, and each policy is attached at one level. When more than one attachment could apply, the most specific wins: security integration, then user, then account.

How it works: one connection, step by step

For each connection Snowflake picks exactly one policy, the most specific one that applies. Then it compares the address with that policy's lists. An address must match the allowed list to connect. If it also matches the blocked list, it is refused, because blocked wins on overlap. That is how you remove one compromised machine from a trusted range. A policy with no allowed IPv4 entries allows no IPv4 address at all. Never read an empty allowed list as "no restriction." When a request arrives over a private connection, the private-endpoint rules apply to it rather than the IPv4 rules.

How one connection is checked. First Snowflake picks a single policy: the one on the security integration if the connection uses one that has a policy, else the user's policy, else the account's. Then the address must match that policy's allowed list and must not match its blocked list. Only then does authentication continue. Only SCIM and OAuth security integrations can carry a network policy.Security integrationwith a network policy?Userwith a network policy?Use the integrationpolicyUse the userpolicyUse the accountpolicyIn theallowed list?In theblocked list?Connection allowedauthentication startsRefusedRefusedblocked winsExactly one policy is evaluated: the most specific one that applies.yesnoyesnonoyesyesno

Security integrationwith a network policy?

yes

Use the integrationpolicy

no

Userwith a network policy?

yes

Use the userpolicy

no

Use the accountpolicy

In theallowed list?

no

Refused

yes

In theblocked list?

yes

Refusedblocked wins

no

Connection allowedauthentication starts

Exactly one policy is evaluated: the most specific one that applies.

Figure 3.13 The check for one connection. Snowflake first selects a single policy (integration, else user, else account), then requires an allowed-list match and no blocked-list match. Only then does authentication continue. Only SCIM and OAuth security integrations can carry a network policy.

Worked example: IsmaFrost's rules

-- MODE = INGRESS: the rule describes traffic coming INTO Snowflake, which is what network policies filter.
CREATE NETWORK RULE security_db.rules.paris_office
  TYPE = IPV4 MODE = INGRESS VALUE_LIST = ('203.0.113.0/24');      -- 256 office addresses
CREATE NETWORK RULE security_db.rules.vpn_exit
  TYPE = IPV4 MODE = INGRESS VALUE_LIST = ('198.51.100.0/28');     -- where VPN traffic reaches the internet
CREATE NETWORK RULE security_db.rules.etl_server
  TYPE = IPV4 MODE = INGRESS VALUE_LIST = ('192.0.2.7/32');        -- one server
CREATE NETWORK RULE security_db.rules.tableau_range
  TYPE = IPV4 MODE = INGRESS VALUE_LIST = ('198.51.100.64/27');    -- Tableau Cloud's published range

CREATE NETWORK POLICY corp_policy
  ALLOWED_NETWORK_RULE_LIST = ('security_db.rules.paris_office', 'security_db.rules.vpn_exit');
CREATE NETWORK POLICY etl_only
  ALLOWED_NETWORK_RULE_LIST = ('security_db.rules.etl_server');
CREATE NETWORK POLICY tableau_policy
  ALLOWED_NETWORK_RULE_LIST = ('security_db.rules.tableau_range');

ALTER USER youness SET NETWORK_POLICY = corp_policy;  -- test on yourself first
ALTER ACCOUNT SET NETWORK_POLICY = corp_policy;       -- then the whole account
ALTER USER svc_etl SET NETWORK_POLICY = etl_only;     -- overrides the account policy
ALTER SECURITY INTEGRATION tableau_oauth SET NETWORK_POLICY = tableau_policy;  -- overrides both

-- Older policies list addresses directly. Still valid, harder to reuse.
CREATE NETWORK POLICY legacy_policy
  ALLOWED_IP_LIST = ('203.0.113.0/24') BLOCKED_IP_LIST = ('203.0.113.99');

When Alice opens a Tableau Cloud dashboard, the query comes from Tableau's servers, so Snowflake sees Tableau's published addresses, not her laptop. That connection uses the tableau_oauth integration, so TABLEAU_POLICY is the policy checked. Without it, CORP_POLICY would have to list Tableau's range. Her Snowsight logins still follow CORP_POLICY.

Go deeper · INGRESS, EGRESS and the VPN rule name

MODE = INGRESS means traffic coming into Snowflake, which is what network policies filter. EGRESS describes Snowflake calling out to the internet; it belongs to external access integrations, never to network policies. The rule vpn_exit holds the addresses where IsmaFrost's VPN traffic leaves for the internet, so that is the source Snowflake sees when a VPN user connects.

Production ScenarioIsmaFrost · a leaked key

The pipeline's service user svc_etl authenticates with a key pair from one server. In March a private key turns up in a public repository. Because etl_only allows exactly one /32 address, the key is useless from anywhere else. Youness rotates the key through the second key slot that afternoon.

Amine works for an outside agency and connects from its network. Rather than widen the account policy, Youness attaches a user-level policy to AMINE with the agency's range. Only one policy is evaluated, so for Amine the user policy replaces CORP_POLICY: he can now connect from the agency and no longer from the Paris office. If he needs both, his policy lists both rules. Later an office workstation is compromised. Youness puts its single address in a rule and adds that rule to the blocked list of corp_policy. That one machine is refused even though it sits inside the allowed /24.

CREATE NETWORK RULE security_db.rules.agency_range
  TYPE = IPV4 MODE = INGRESS VALUE_LIST = ('192.0.2.128/28');
CREATE NETWORK POLICY agency_policy
  ALLOWED_NETWORK_RULE_LIST = ('security_db.rules.agency_range');
ALTER USER amine SET NETWORK_POLICY = agency_policy;      -- replaces corp_policy for Amine only

CREATE NETWORK RULE security_db.rules.bad_host
  TYPE = IPV4 MODE = INGRESS VALUE_LIST = ('203.0.113.99/32');
ALTER NETWORK POLICY corp_policy
  SET BLOCKED_NETWORK_RULE_LIST = ('security_db.rules.bad_host');  -- blocked wins over the allowed /24

Limits and traps: rolling out safely

Snowflake won't let you activate an account-level policy that blocks the address you're connected from, which protects you from locking yourself out in one statement. The documentation states that guard for the account level only. Policies also affect sessions already in progress: once a policy restricts a logged-in user's address, that user can't run further queries. That's why Youness attaches a new policy to his own user first, reconnects to check, and only then sets it on the account. If he gets it wrong, the backup ACCOUNTADMIN can undo it.

Category trap

"Use a network policy so European analysts see only European rows" is wrong by category. Network policies decide whether a connection exists. Which rows a session sees is a row access policy.

Exam takeaway
  • Network policies restrict connection sources only: IPv4 ranges or private endpoints, through network rules or legacy IP lists.
  • Precedence: security integration > user > account. Only the most specific applicable policy is evaluated.
  • Blocked overrides allowed on overlap. No allowed IPv4 entries means no IPv4 address is allowed.
  • Your own address must be allowed before you can activate an account-level policy, and existing sessions are affected.