Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Cloud Desktop
    • Yandex SIEM
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • Serverless Integrations
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Yandex Query
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Smart Web Security
  • Getting started
    • All guides
      • Creating a profile
      • Editing basic profile settings
      • Getting profile information
      • Deleting a profile
      • Configuring rule sets
      • Getting information about a rule set
      • Adding an exclusion rule
      • Updating an exclusion rule
      • Deleting an exclusion rule
    • Address lists
    • Viewing operations
    • Configuring monitoring
    • Setting up alerts
    • Configuring logs via Smart Web Security
    • Configuring logs via Application Load Balancer
    • Migrating to the new condition format in the API, CLI, and Terraform
    • Overview
    • Security profiles
    • WAF
    • ARL (request limit)
    • Rules
    • Conditions
    • Lists
    • Managing bot traffic
    • Protecting domains
    • Response templates
    • Logging
    • Quotas and limits
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  1. Step-by-step guides
  2. WAF profiles
  3. Configuring rule sets

Configuring WAF rule sets

Written by
Yandex Cloud
Updated at September 17, 2026
View in Markdown
Management console
Terraform
API
  1. In the management console, select the folder containing the WAF profile.

  2. Navigate to Smart Web Security.

  3. In the left-hand panel, select WAF profiles.

  4. Select the profile where you want to configure rule sets.

  5. Click Configure next to the rule set.

  6. To configure your OWASP set:

    1. Set the Anomaly threshold, which is the total anomaly score of triggered rules that results in blocking the request.

      We recommend that you start with an anomaly threshold of 25 and gradually reduce it to 5. To reduce the anomaly threshold, address WAF false positives triggered by legitimate requests. To do so, select rules from the basic set and configure exclusion rules.

      Use Only logging (dry run) mode to test anomaly thresholds. The mode gets activated when you add a WAF rule to the security profile.

    2. Set the Paranoia level.

      The paranoia level classifies rules based on how aggressive they are. The higher the paranoia level, the better the protection, but also the greater the risk of WAF false positives.

    3. Test the rules included in the set. Optionally, add additional rules or remove those you do not need. When using rules, pay attention to their anomaly scores and paranoia levels.

      You can make any rule in the set the blocking one. WAF will block any request conforming to such a rule irrespective of the anomaly threshold. To turn a rule into a blocking one, click on its right. If you have enabled the Only logging (dry run) mode in the security profile, WAF will not be blocking requests.

  7. To configure your Yandex Ruleset:

    1. Enable the rule groups you want to apply as part of the set.

      In Yandex Ruleset, you can configure each rule group individually.

    2. Expand and specify the parameters for each rule group you enabled:

      1. Optionally, change Anomaly threshold from 1 to 10000. The default value is 7, since the Yandex Ruleset produces the fewest false positives.

      2. Select the When threshold is exceeded action to perform on a request in this case. Currently, only request blocking is available.

      3. Disable the rules you do not want to apply as part of the set.

      4. If you want a rule to immediately block the request regardless of its total anomaly, click to the right of the rule.

  8. To configure your Yandex ML Ruleset:

    1. Enable the rules you want to apply as part of the set.
    2. Optionally, change Anomaly threshold from 1 to 100. The default value is 90. A low anomaly threshold may result in frequent false positives.
  9. Click Save settings.

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the guides on the Terraform website or its mirror.

If you do not have Terraform yet, install it and configure the Yandex Cloud provider.

To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), authenticate using the appropriate method.

You can dynamically activate all the basic set rules if their paranoia level is not higher than the custom variable. For dynamic rules, you can edit the settings manually. For example, you can turn a rule into a blocking one and enable a rule with the paranoia level higher than the one defined in the variable.

  1. Open the Terraform configuration file and edit the WAF profile description fragment yandex_sws_waf_profile: add either the rule section with a security rule or the dynamic "rule" section with dynamically configured rules.

    # Declaring local variables
    locals {
      # In the basic set, rules of this paranoia level and below will be enabled
      waf_paranoia_level = <paranoia_level>
    }
    
    # Data source: rule set
    data "yandex_sws_waf_rule_set_descriptor" "source" {
      name    = "<set_name>"
    }
    
    # WAF profile
    resource "yandex_sws_waf_profile" "default" {
      name = "default"
    
      ...
    
      # Turning the rule into a blocking one: the request will be blocked regardless of the anomaly threshold
      rule {
        rule_id     = "<rule_1_ID>"
        is_enabled  = true
        is_blocking = true
      }
    
      # Enabling the rule with paranoia level 4
      rule {
        rule_id     = "<rule_2_ID>"
        is_enabled  = true
        is_blocking = false
      }
    
      # Enabling rules from the basic set if their paranoia level is not higher than the value defined in the waf_paranoia_level variable
      dynamic "rule" {
        for_each = [
          for rule in data.yandex_sws_waf_rule_set_descriptor.source.rules : rule
          if rule.paranoia_level <= local.waf_paranoia_level
        ]
        content {
          rule_id     = rule.value.id
          is_enabled  = true
          is_blocking = false
        }
      }
    }
    
    Example of configuring WAF profile rule sets in your Terraform configuration
    # Declaring local variables
    locals {
      # In the basic set, rules of this paranoia level and below will be enabled
      waf_paranoia_level = 1
    
      # OWASP Core Ruleset identification
      ruleset_name    = "OWASP Core Ruleset"
      ruleset_version = "4.0.0"
      ruleset_id      = "OWASP_CRS_4_0_0"
      ruleset_type    = "CORE"
    }
    
    # OWASP Core Rule Set data source
    data "yandex_sws_waf_rule_set_descriptor" "source" {
      name    = local.ruleset_name
      version = local.ruleset_version
    }
    
    # WAF profile
    resource "yandex_sws_waf_profile" "default" {
      name = "default"
    
      # Basic rule set
      rule_set {
        action     = "DENY"
        is_enabled = true
        priority   = 1
        core_rule_set {
          inbound_anomaly_score = 2
          paranoia_level        = local.waf_paranoia_level
          rule_set {
            name    = local.ruleset_name
            version = local.ruleset_version
            id      = local.ruleset_id
            type    = local.ruleset_type
          }
        }
      }
    
      # Turning the rule into a blocking one: the request will be blocked regardless of the anomaly threshold
      rule {
        rule_id     = "owasp-crs-v4.0.0-id942330-attack-sqli"
        is_enabled  = true
        is_blocking = true
      }
    
      # Enabling the rule with paranoia level 4
      rule {
        rule_id     = "owasp-crs-v4.0.0-id920202-protocol-enforcement"
        is_enabled  = true
        is_blocking = false
      }
    
      # Enabling rules from the basic set if their paranoia level is not higher than the value defined in the waf_paranoia_level variable
      dynamic "rule" {
        for_each = [
          for rule in data.yandex_sws_waf_rule_set_descriptor.source.rules : rule
          if rule.paranoia_level <= local.waf_paranoia_level
        ]
        content {
          rule_id     = rule.value.id
          is_enabled  = true
          is_blocking = false
        }
      }
    }
    

    Where:

    • rule: Security rule description:

      • rule_id: Rule ID.
      • is_enabled: Flag to enable or disable a rule.
      • is_blocking: Blocking rule flag. If true, the rule becomes the blocking one.
    • dynamic "rule": Dynamic activation of the basic set rules if their paranoia level is not higher than the waf_paranoia_level variable. For dynamic rules, you can edit the settings manually. For example, you can turn a rule into a blocking one or enable a rule with the paranoia level higher than the one defined in the variable.

      • rule_id: Rule ID.
      • is_enabled: Flag to enable or disable a rule.
      • is_blocking: Blocking rule flag. If true, the rule becomes the blocking one.

    For more on the properties of the yandex_sws_waf_profile resource, see this provider guide.

  2. Apply the changes:

    1. In the terminal, navigate to the configuration file directory.

    2. Make sure the configuration is correct using this command:

      terraform validate
      

      If the configuration is valid, you will get this message:

      Success! The configuration is valid.
      
    3. Run this command:

      terraform plan
      

      You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.

    4. Apply the configuration changes:

      terraform apply
      
    5. Type yes and press Enter to confirm the changes.

You can check the update in the management console.

Use the update REST API method for the WafProfile resource or the WafProfile/Update gRPC API call.

Each time you update or add WAF profile rules, enable the Only logging mode. Activate a rule only after the logs confirm that it works correctly. This way you will avoid false positives and ensure stable operation of your website or web application.

Useful linksUseful links

  • Adding a WAF exclusion rule
  • Adding a rule to a security profile
  • Setting up basic protection in Smart Web Security

Was the article helpful?

Previous
Deleting a profile
Next
Getting information about a rule set
© 2026 Direct Cursus Technology L.L.C.