組織向けのインターネットおよび SaaS アプリのセキュリティ戦略を構築するには、次のネットワークポリシーを追加することを推奨します。
よく使うネットワークポリシーの追加例は 一般的なネットワークポリシー を参照してください。ネットワークポリシーの作成方法は ネットワークポリシー を参照してください。
リスクの高いユーザー向けの identity provider (IdP) ユーザーグループに含まれるユーザーのアクセスを制限します。このポリシーにより、セキュリティチームは、悪意のある、または不審なアクティビティが検出されたユーザーのトラフィックを制限できます。
| セレクター | 演算子 | 値 | 論理 | アクション |
|---|---|---|---|---|
| Destination IP | not in list | Quarantined-Users-IPAllowlist | Or | Block |
| SNI | not in list | Quarantined-Users-HostAllowlist | Or | |
| SNI Domain | not in list | Quarantined-Users-DomainAllowlist | And | |
| User Group Names | in | Quarantined Users |
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "Quarantined-Users-NET-Restricted-Access",
"description": "Restrict access for users included in an IdP user group for risky users",
"precedence": 0,
"enabled": true,
"action": "block",
"filters": [
"l4"
],
"traffic": "not(net.dst.ip in $<IP_ALLOWLIST_UUID>) or not(net.sni.host in $<HOST_ALLOWLIST_UUID>) or not(any(net.sni.domains[] in $<DOMAIN_ALLOWLIST_UUID>))",
"identity": "any(identity.groups.name[] in {\"Quarantined Users\"})"
}'resource "cloudflare_zero_trust_gateway_policy" "quarantined_users_net_restricted_access" {
account_id = var.cloudflare_account_id
name = "Quarantined-Users-NET-Restricted-Access"
description = "Restrict access for users included in an IdP user group for risky users"
precedence = 0
enabled = true
action = "block"
filters = ["l4"]
traffic = "not(net.dst.ip in ${"$"}${cloudflare_zero_trust_list.ip_allowlist.id}) or not(net.sni.host in ${"$"}${cloudflare_zero_trust_list.host_allowlist.id}) or not(any(net.sni.domains[*] in ${"$"}${cloudflare_zero_trust_list.domain_allowlist.id}))"
identity = "any(identity.groups.name[*] in {\"Quarantined Users\"})"
}ベースラインのポスチャチェックに合格していないデバイスのアクセスを制限します。ポスチャチェックを Crowdstrike や Intune などのサービスプロバイダーと API で連携している場合、あらかじめ決めたセキュリティ要件を満たさないデバイスへのアクセスを、このポリシーが動的にブロックします。
リスクの高いユーザー向けの identity provider (IdP) ユーザーグループに含まれるユーザーのアクセスを制限します。このポリシーにより、セキュリティチームは、悪意のある、または不審なアクティビティが検出されたユーザーのトラフィックを制限できます。
| セレクター | 演算子 | 値 | 論理 | アクション |
|---|---|---|---|---|
| Destination IP | not in list | Posture-Fail-IPAllowlist | Or | Block |
| SNI | not in list | Posture-Fail-HostAllowlist | Or | |
| SNI Domain | not in list | Posture-Fail-DomainAllowlist | And | |
| Passed Device Posture Checks | not in | Windows 10 or higher (OS version) |
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "Posture-Fail-NET-Restricted-Access",
"description": "Restrict access for devices where baseline posture checks have not passed",
"precedence": 10,
"enabled": true,
"action": "block",
"filters": [
"l4"
],
"traffic": "not(net.dst.ip in $<IP_ALLOWLIST_UUID>) or not(net.sni.host in $<HOST_ALLOWLIST_UUID>) or not(any(net.sni.domains[] in $<DOMAIN_ALLOWLIST_UUID>))",
"device_posture": "not(any(device_posture.checks.passed[] in {\"<DEVICE_POSTURE_CHECK_UUID>\"}))"
}'resource "cloudflare_zero_trust_gateway_policy" "posture_fail_net_restricted_access" {
account_id = var.cloudflare_account_id
name = "Posture-Fail-NET-Restricted-Access"
description = "Restrict access for devices where baseline posture checks have not passed"
precedence = 10
enabled = true
action = "block"
filters = ["l4"]
traffic = "not(net.dst.ip in ${"$"}${cloudflare_zero_trust_list.ip_allowlist.id}) or not(net.sni.host in ${"$"}${cloudflare_zero_trust_list.host_allowlist.id}) or not(any(net.sni.domains[*] in ${"$"}${cloudflare_zero_trust_list.domain_allowlist.id}))"
device_posture = "not(any(device_posture.checks.passed[*] in {\"${cloudflare_device_posture_rule.baseline_check.id}\"}))"
}必要に応じて、ディスク暗号化 や ドメイン参加 など、Cloudflare One Client のデバイスポスチャチェックを追加できます。デバイスポスチャチェックの詳細は デバイスポスチャを適用する を参照してください。
ユーザーグループに HTTPS アクセスを許可します。たとえば次のポリシーは、財務担当ユーザーに既知の財務アプリケーションへのアクセスを与えます。
| セレクター | 演算子 | 値 | 論理 | アクション |
|---|---|---|---|---|
| Destination IP | in list | Finance Servers | And | Allow |
| User Group Names | in | Finance Users |
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "FinanceUsers-NET-HTTPS-FinanceServers",
"description": "Allow HTTPS access for user groups",
"precedence": 20,
"enabled": true,
"action": "allow",
"filters": [
"l4"
],
"traffic": "net.dst.ip in $<FINANCE_SERVERS_LIST_UUID>",
"identity": "any(identity.groups.name[*] in {\"Finance Users\"})"
}'resource "cloudflare_zero_trust_gateway_policy" "finance_users_net_https_finance_servers" {
account_id = var.cloudflare_account_id
name = "FinanceUsers-NET-HTTPS-FinanceServers"
description = "Allow HTTPS access for user groups"
precedence = 20
enabled = true
action = "allow"
filters = ["l4"]
traffic = "net.dst.ip in ${"$"}${cloudflare_zero_trust_list.finance_servers_list.id}"
identity = "any(identity.groups.name[*] in {\"Finance Users\"})"
}組織に脅威となる、または悪意のある宛先 IP、SNI、SNI ドメインへのトラフィックをブロックします。
このポリシーは、カスタムブロックリストを作成するか、脅威インテリジェンスパートナーや地域の Computer Emergency and Response Teams(CERT)が提供するブロックリストを使って実装できます。理想的には、CERT が API 自動化 でブロックリストを更新し、リアルタイムの脅威保護を提供します。
| セレクター | 演算子 | 値 | 論理 | アクション |
|---|---|---|---|---|
| Destination IP | in list | IP Blocklist | Or | Block |
| SNI | in list | Host Blocklist | Or | |
| SNI Domain | in list | Domain Blocklist |
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "All-NET-Internet-Blocklist",
"description": "Block traffic to malicious or risky destination IPs, SNIs, and SNI domains",
"precedence": 30,
"enabled": true,
"action": "block",
"filters": [
"l4"
],
"traffic": "net.dst.ip in $<IP_BLOCKLIST_UUID> and net.sni.host in $<HOST_BLOCKLIST_UUID> and any(net.sni.domains[*] in $<DOMAIN_BLOCKLIST_UUID>)"
}'resource "cloudflare_zero_trust_gateway_policy" "finance_users_net_https_finance_servers" {
account_id = var.cloudflare_account_id
name = "All-NET-Internet-Blocklist"
description = "Block traffic to malicious or risky destination IPs, SNIs, and SNI domains"
precedence = 30
enabled = true
action = "block"
filters = ["l4"]
traffic = "net.dst.ip in ${"$"}${cloudflare_zero_trust_list.ip_blocklist.id} and net.sni.host in ${"$"}${cloudflare_zero_trust_list.host_blocklist.id} and any(net.sni.domains[*] in ${"$"}${cloudflare_zero_trust_list.domain_blocklist.id})"
}特定のユーザーが、インターネット上の特定のエンドポイントへ SSH トラフィックを送れるようにします。アクセスが必要な他の非ウェブエンドポイントにも、同様のポリシーを作成できます。
必要に応じて、送信元 IP または IdP グループで絞り込むセレクターを追加できます。
| セレクター | 演算子 | 値 | 論理 | アクション |
|---|---|---|---|---|
| Destination IP | in list | SSHAllowList | Or | Allow |
| SNI | in list | SSHAllowlistFQDN | And | |
| Detected Protocol | is | SSH | And | |
| User Group Names | in | SSH-Allowed-Users |
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "All-NET-SSH-Internet-Allowlist",
"description": "Allow SSH traffic to specific endpoints on the Internet for specific users",
"precedence": 40,
"enabled": true,
"action": "allow",
"filters": [
"l4"
],
"traffic": "net.dst.ip in $<SSH_IP_ALLOWLIST_UUID> and net.sni.host in $<SSH_FQDN_ALLOWLIST_UUID> and net.detected_protocol == \"ssh\"",
"identity": "any(identity.groups.name[*] in {\"SSH-Allowed-Users\"})"
}'resource "cloudflare_zero_trust_gateway_policy" "all_net_ssh_internet_allowlist" {
account_id = var.cloudflare_account_id
name = "All-NET-SSH-Internet-Allowlist"
description = "Allow SSH traffic to specific endpoints on the Internet for specific users"
precedence = 40
enabled = true
action = "allow"
filters = ["l4"]
traffic = "net.dst.ip in ${"$"}${cloudflare_zero_trust_list.ssh_ip_allowlist.id} and net.sni.host in ${"$"}${cloudflare_zero_trust_list.ssh_fqdn_allowlist.id} and net.detected_protocol == \"ssh\""
identity = "any(identity.groups.name[*] in {\"SSH-Allowed-Users\"})"
}インターネット向けの非ウェブトラフィックをすべてブロックします。Detected Protocol セレクターを使うと、HTTP と HTTPS の代替ポートは許可されます。
| セレクター | 演算子 | 値 | 論理 | アクション |
|---|---|---|---|---|
| Destination IP | not in list | InternalNetwork | And | Block |
| Detected Protocol | not in | HTTP, HTTP2 |
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "All-NET-NO-HTTP-HTTPS-Internet-Deny",
"description": "Block all non-web traffic towards the Internet",
"precedence": 50,
"enabled": true,
"action": "block",
"filters": [
"l4"
],
"traffic": "not(net.dst.ip in $<INTERNAL_NETWORK_IP_LIST_UUID>) and not(net.detected_protocol in {\"http\" \"http2\"})"
}'resource "cloudflare_zero_trust_gateway_policy" "all_net_no_http_https_internet_deny" {
account_id = var.cloudflare_account_id
name = "All-NET-NO-HTTP-HTTPS-Internet-Deny"
description = "Block all non-web traffic towards the Internet"
precedence = 50
enabled = true
action = "block"
filters = ["l4"]
traffic = "not(net.dst.ip in ${"$"}${cloudflare_zero_trust_list.internal_network_ip_list.id}) and not(net.detected_protocol in {\"http\" \"http2\"})"
}リストに含めた内部 IP 範囲を、暗黙的にすべて拒否します。上記のポリシーで定義したトラフィックを明示的に許可するため、このポリシーは ポリシーリストの一番下 に置くことを推奨します。
| セレクター | 演算子 | 値 | アクション |
|---|---|---|---|
| Destination IP | in list | Internal Network IPs | Block |
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "All-NET-InternalNetwork-ImplicitDeny",
"description": "Implicitly deny all of your internal IP ranges included in a list",
"precedence": 60,
"enabled": true,
"action": "block",
"filters": [
"l4"
],
"traffic": "net.dst.ip in $<INTERNAL_NETWORK_IP_LIST_UUID>"
}'resource "cloudflare_zero_trust_gateway_policy" "all_net_internalnetwork_implicitdeny" {
account_id = var.cloudflare_account_id
name = "All-NET-InternalNetwork-ImplicitDeny"
description = "Implicitly deny all of your internal IP ranges included in a list"
precedence = 60
enabled = true
action = "block"
filters = ["l4"]
traffic = "net.dst.ip in ${"$"}${cloudflare_zero_trust_list.internal_network_ip_list.id}"
}既知で承認済みのデバイスからのネットワークトラフィックだけを許可します。
次の例では、デバイスのシリアル番号 のリストを使い、会社のデバイスから Cloudflare One Client で接続している場合にだけアプリケーションへアクセスできるようにできます。
| セレクター | 演算子 | 値 | 論理 | アクション |
|---|---|---|---|---|
| SNI Domain | is | internalapp.com |
And | Block |
| Passed Device Posture Checks | not in | Device serial numbers |
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "All-NET-ApplicationAccess-Allow",
"description": "Ensure access to the application comes from authorized WARP clients",
"precedence": 70,
"enabled": false,
"action": "block",
"filters": [
"l4"
],
"traffic": "any(net.sni.domains[*] == \"internalapp.com\")",
"device_posture": "not(any(device_posture.checks.passed[*] in {\"<DEVICE_SERIAL_NUMBERS_LIST_UUID>\"}))"
}'デバイスポスチャチェックの UUID を取得するには、List device posture rules エンドポイントを使います。
resource "cloudflare_zero_trust_gateway_policy" "all_net_applicationaccess_allow" {
account_id = var.cloudflare_account_id
name = "All-NET-ApplicationAccess-Allow"
description = "Ensure access to the application comes from authorized WARP clients"
precedence = 70
enabled = false
action = "block"
filters = ["l4"]
traffic = "any(net.sni.domains[*] == \"internalapp.com\")"
posture = "not(any(device_posture.checks.passed[*] in {\"${"$"}${cloudflare_zero_trust_list.allowed_devices_sn_list.id}\"}))"
}