Cloud Armor Crs Rule Upgrader
GoogleOfficialPublished by Google
- Skill
- Workflow
- Security
- Apache-2.0
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured workflow for Google Cloud practitioners to transition Cloud Armor WAF rules to OWASP CRS 4.22. It includes a Python CLI tool for parsing policy definitions, remapping signature IDs, and handling rule exclusions. The workflow emphasizes operational safety by offering both in-place upgrades and preview-mode deployments, while providing guardrails for rule quotas and priority management. It specifically addresses breaking changes, such as updated method enforcement, and ensures that legacy configuration parameters are correctly translated to the current WAF syntax.
What it does
- Audits existing Cloud Armor policies for legacy OWASP CRS 3.0 and 3.3 rules.
- Translates legacy ruleset names and CEL expressions to CRS 4.22 standards.
- Remaps signature IDs and filters out retired CRS 3.0/3.3 signatures.
- Supports preview-mode deployments to validate rule changes without blocking traffic.
- Provides risk assessment for potential breaking changes like Method Enforcement.
- Maintains existing fine-tuning exclusions and custom rule configurations.
When to use it
- When upgrading Google Cloud Armor security policies to OWASP CRS 4.22.
- When auditing legacy WAF rules to identify signature coverage expansions.
- When preparing to transition WAF rules while minimizing the risk of blocking legitimate traffic.
- When needing to verify rule changes via telemetry in Cloud Logging before full enforcement.
Advantages
- Reduces manual effort in remapping complex WAF signature IDs.
- Prevents accidental traffic blocking through preview-mode validation.
- Ensures consistent handling of rule exclusions and custom configurations.
- Provides clear guidance on operational risks and breaking changes.
Usage examples
- “Audit my Cloud Armor policy named ecommerce-waf for legacy OWASP rules.”
- The agent will provide the gcloud command to fetch the policy JSON and guide you through identifying legacy rulesets and signature coverage expansions.
- “Upgrade my security policy to CRS 4.22 using preview mode.”
- The agent will use the upgrade script to generate preview rules at a lower priority, allowing you to inspect telemetry in Cloud Logging before applying changes.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/google/cloud-armor-crs-rule-upgrader/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip cloud-armor-crs-rule-upgrader.zip -d .agents/skills
Documentation by Google
Cloud Armor OWASP Rule Upgrader (CRS 3.0/3.3 -> 4.22)
<!-- disableFinding(LINE_OVER_80) -->
This skill guides Network Security Agents and Google Cloud practitioners through auditing, assessing, and upgrading Google Cloud Armor security policies from legacy OWASP Core Rule Set (CRS) 3.0 or 3.3 to OWASP CRS 4.22.
Usage Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you
MUST read and follow the instructions in
Usage Attribution.
Prerequisites and Environment Setup
Before auditing or modifying Google Cloud Armor security policies, ensure the following prerequisites are met:
Google Cloud SDK: Install or update the Google Cloud CLI (
gcloud).Project Selection and Active Billing: Select your target Google Cloud project and verify that an active billing account is attached:
gcloud config set project PROJECT_ID gcloud billing projects describe PROJECT_ID --format="value(billingEnabled)"API Enablement: Enable the Compute Engine API (for Cloud Armor security policies) and Cloud Logging API (for preview mode telemetry):
gcloud services enable compute.googleapis.com logging.googleapis.comAuthentication:
Interactive CLI:
gcloud auth loginApplication Default Credentials (ADC):
gcloud auth application-default loginService Accounts: Set
GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json".
Required IAM Roles:
roles/compute.securityAdmin: Required to create, update, delete, or import Cloud Armor security policies and rules (useroles/compute.securityViewerfor read-only policy audits).roles/logging.viewer: Required to inspect HTTP load balancer preview telemetry in Cloud Logging.
Scope and Regional Availability:
Cloud Armor security policies can be Global (default for global external Application Load Balancers) or Regional (for regional external Application Load Balancers, for example,
--region=us-central1; set a default region viagcloud config set compute/region us-central1). See Google Cloud Locations for regional availability.
Pricing and Resource Cleanup:
Cloud Armor incurs charges per security policy, per rule, and per million requests depending on your tier (Standard vs. Enterprise); check Google Cloud Armor Pricing for current rates.
Teardown / Cleanup: Always delete temporary
--previewrules (gcloud compute security-policies rules delete PREVIEW_PRIORITY --security-policy="POLICY_NAME") or standalone test policies (gcloud compute security-policies delete TEST_POLICY_NAME) after cutover to avoid leaving orphan rules that consume policy quota or incur recurring rule charges.
Quick Start and CLI Helper
For automated, deterministic parsing, signature remapping, and preview-mode priority allocation, invoke the bundled standalone Python CLI:
# In-Place Upgrade (Report Summary)
python3 scripts/upgrade_policy.py /path/to/policy.json --mode=in-place --format=report
# In-Place Upgrade (Output gcloud commands)
python3 scripts/upgrade_policy.py /path/to/policy.json --mode=in-place --format=gcloud
# Preview Mode Upgrade (Generates preview rules at priority - 5)
python3 scripts/upgrade_policy.py /path/to/policy.json --mode=preview --format=gcloud
# Direct stdin piping from gcloud describe
gcloud compute security-policies describe POLICY_NAME --format=json | \
python3 scripts/upgrade_policy.py - --mode=preview --format=jsonSee gcloud_recipes.md for full command workflows.
Core Upgrade Workflow for Network Security Agent
[!IMPORTANT] Mandatory Agent Response Behaviors: 1. Explain Both Upgrade Modes: Whenever discussing an upgrade (even if the user asks specifically about Preview Mode or In-Place), ALWAYS explain BOTH In-Place Upgrade (direct in-situ rule replacement, immediate enforcement, zero extra quota) and Preview Mode (preview rules deployed at lower numeric priority numbers with
preview = true, zero risk of blocking traffic, allows telemetry inspection in Cloud Logging before cutover). 2. Handling Policy Audit Inquiries: When asked to audit or inspect a policy (such as'ecommerce-waf'), if policy JSON is not provided orgcloud describecannot reach Google Cloud resources, immediately provide thegcloud compute security-policies describe POLICY_NAME --format=jsoncommand and guide the user through the audit checks: - Check for legacy OWASP 3.0 / 3.3 rulesets (sqli-stable,xss-stable,rce-stable,methodenforcement-stable, orevaluatePreconfiguredExpr). - Report in-scope WAF rules versus pass-through custom rules (such as IP allowlistsSRC_IPS_V1, rate limiting, or default rulespriority: 2147483647). - Highlight signature count expansions under CRS 4.22 (for example, RCE expanding from 11/15 to 44 signatures; SQLi expanding to 60 signatures).
When interacting with a customer to upgrade a Cloud Armor security policy, execute this 5-step workflow:
Discover and Fetch: Identify the target security policy and fetch its JSON definition.
Audit and Classify Risk: Inspect rules, signature count expansions, and operational risk levels.
Confirm Mode and Method Risk: Align with the customer on Preview Mode versus In-Place Upgrade, method enforcement risk, and quota or priority constraints.
Transform Rules: Translate ruleset names, CEL expressions, signature IDs, and
preconfiguredWafConfigexclusions to CRS 4.22.Execute and Verify: Apply the upgrade via
gcloudand verify telemetry in Cloud Logging.
Step 1: Policy Discovery and Ingestion
Identify the target security policy name and Google Cloud project.
Fetch the current policy definition via
gcloud:gcloud compute security-policies describe POLICY_NAME --project=PROJECT_ID --format="json"If policy JSON is not provided or executing in conversational mode, provide the
gcloud describecommand and outline the audit criteria below.Inspect the
ruleslist:Identify in-scope WAF rules: calls to
evaluatePreconfiguredWaforevaluatePreconfiguredExprusing legacy 3.0 / 3.3 rulesets (sqli-stable,xss-stable,rce-stable,methodenforcement-stable, etc.).Identify out-of-scope rules: pass-through custom rules (such as pure IP allowlists
SRC_IPS_V1, rate limiting, header matches without WAF calls, or default rulespriority: 2147483647). Pass these through unchanged.Highlight signature coverage expansions (for example, RCE expanding from 11/15 to 44 signatures; SQLi expanding to 60 signatures in CRS 4.22).
Step 2: Audit and Risk Classification
Evaluate each in-scope rule against standard operational risk categories:
<!-- mdformat off -->
| Risk Level | Impact Category | Criteria and Recommended Action |
|---|---|---|
| 🔴 High Risk | Breaking Change | Immediate risk of blocking legitimate production traffic upon cutover. Example: methodenforcement-v422-stable only permits GET, HEAD, POST, OPTIONS, and blocks PUT, PATCH, DELETE requests. Requires customer confirmation and API path/signature exemptions. |
| 🟡 Medium Risk | Attention Required | Behavioral shifts that should be validated in Preview Mode before enforcement:<br>• Coverage Expansion: Sensitivity level 4 activates significantly more signatures (for example, RCE expands from 11/15 to 44 signatures; SQLi expands to 60 signatures).<br>• Deprecated Exemption Lost: Legacy rule opted out of any of the 15 retired CRS 3.0/3.3 IDs (981172, 981173, 980130, 949110; SQLi: 942110; RCE: 932100, 932105, 932106, 932110, 932115, 932150; Scanner Detection: 913101, 913102, 913110, 913120), which are omitted in 4.22.<br>• Custom Filter Continuity: Preserved custom header/cookie/query/IP conditions combined with WAF calls. |
| 🟢 Low Risk | Clean Upgrade | Direct 1:1 ruleset translation with preserved active opt-outs and no expected behavioral divergence (for example, standard SQLi or XSS rules). |
| ⚪ No Action | Pass-Through | Non-OWASP rules (pure IP allowlist/denylist, rate limiting, default rule). Carried over unchanged. |
<!-- mdformat on -->
Step 3: Upgrade Mode Selection and User Alignment
Engage the customer with findings before applying changes:
Report Findings: State how many WAF rules will be upgraded, signature coverage expansions, and any deprecated signatures being retired.
Method Enforcement Warning: If
methodenforcementis present, warn: > "Notice: Method Enforcement in CRS 4.22 permits only GET, HEAD, POST, and OPTIONS. If your application handles REST API updates (PUT, PATCH, DELETE), these methods will be blocked with HTTP 403. Would you like to add an exemption for API paths or opt out of rule id911100?"Explain Differences Between Modes:
Preview Mode (Recommended): Keeps existing legacy rules actively enforcing while deploying corresponding upgraded CRS 4.22 preview rules with
preview = trueat a lower numeric priority number (higher evaluation priority, for example,PRIORITY - 5). Traffic is evaluated first by preview rules and logged to Cloud Logging without blocking, ensuring zero risk of downtime or false positives prior to cutover. Requires sufficient quota under the 200-rule limit.In-Place Upgrade: Directly modifies the CEL expressions and
preconfiguredWafConfigon existing rule priority numbers in-situ. Immediate enforcement with zero additional rule overhead, but carries cutover risk if new signatures or method enforcement block valid traffic.
Quota Guardrail (200 Rules):
Calculate projected rule count:
current_total_rules + in_scope_waf_rules.If projected count > 200, alert the customer: > "Cloud Armor enforces a maximum limit of 200 rules per security policy. Deploying in Preview Mode would require PROJECTED_COUNT rules. The upgrade cannot proceed in Preview Mode. We must either perform an In-Place Upgrade or consolidate rules."
Priority Spacing Guardrail (Preview Mode):
If an in-scope WAF rule at
PRIORITYimmediately follows another rule atPREV_PRIORITYwith no free integer priority slot between them (for example,999and1000, or a WAF rule at priority0), alert the customer: > "Rule PRIORITY cannot be deployed in Preview Mode because the preceding rule at priority PREV_PRIORITY leaves no open priority number between PREV_PRIORITY and PRIORITY (and placing the preview rule above PREV_PRIORITY would change evaluation order). To use Preview Mode, please readjust your rule priorities to leave at least one open priority slot before PRIORITY, or choose an In-Place Upgrade."Do NOT automatically re-number existing customer rules: Because rule priorities act as primary identifiers in Cloud Armor and are often tied to Terraform/IaC resources and SIEM alerting filters, never silently shift existing customer rule priorities to make room. If the customer explicitly asks you to readjust their rule priorities for them, first warn them about potential Terraform/IaC state drift and confirm the exact new priority numbers before executing any priority changes.
Step 4: Rule Transformation Logic
A. Ruleset Name Translation
Translate legacy ruleset names according to the mapping table in ruleset_mappings.md:
Stable:
sqli-stabletosqli-v422-stable,rce-stabletorce-v422-stableCanary:
sqli-canarytosqli-v422-canary3.3 Stable:
sqli-v33-stabletosqli-v422-stable,nodejs-v33-stabletogeneric-v422-stable
B. CEL Opt-Out and Opt-In Translation
Legacy
evaluatePreconfiguredExpr(ruleset, ['id1', 'id2'])is strictly an opt-out (disabled) list.Convert to native 4.22 syntax:
evaluatePreconfiguredWaf('sqli-v422-stable', {'opt_out_rule_ids': ['owasp-crs-v042200-id942120-sqli']})Remap signature IDs:
owasp-crs-v030001-idSIGNATURE_ID-GROUPtoowasp-crs-v042200-idSIGNATURE_ID-GROUP. (Exception: Standalone CVE signatures such ascve-canarysignaturesowasp-crs-v030001-id*-cveandgoogle-mrs-*retain their original IDs and must not be remapped tov042200or dropped).Drop all 15 deprecated CRS 3.0/3.3 signature numbers (
981172,981173,980130,949110; SQLi:942110; RCE:932100,932105,932106,932110,932115,932150; Scanner Detection:913101,913102,913110,913120).
C. Fine-Tuning (preconfiguredWafConfig)
For rules with structured preconfiguredWafConfig.exclusions[]:
Update
targetRuleSetto the CRS 4.22 equivalent.Remap
targetRuleIdstov042200and drop deprecated IDs. Warning: If an exclusion'stargetRuleIdslist becomes empty ([]) after dropping retired IDs, remove the entire exclusion entry rather than leavingtargetRuleIds: [](otherwise an emptytargetRuleIdslist exempts the entire ruleset).Carry over all field exclusions (
requestHeadersToExclude,requestCookiesToExclude,requestQueryParamsToExclude,requestUrisToExclude,requestBodiesToExclude) and match operators without modification.Details in fine_tuning_and_cel.md.
Step 5: Execution Delivery and Verification
Delivering In-Place Upgrade
Execute gcloud compute security-policies rules update:
gcloud compute security-policies rules update PRIORITY \
--security-policy="POLICY_NAME" \
--project=PROJECT_ID \
--expression="UPGRADED_EXPRESSION"Delivering Preview Mode Upgrade
Deploy preview rules at a numeric priority strictly between the immediately
preceding rule and ENFORCED_PRIORITY (PREV_PRIORITY < PREVIEW_PRIORITY < ENFORCED_PRIORITY) using rules create:
gcloud compute security-policies rules create PREVIEW_PRIORITY \
--security-policy="POLICY_NAME" \
--project=PROJECT_ID \
--expression="UPGRADED_EXPRESSION" \
--action="ACTION" \
--preview \
--description="PREVIEW: Upgraded CRS 4.22 Rule for Priority ENFORCED_PRIORITY"Telemetry Verification in Cloud Logging
Instruct the customer to inspect preview logs before cutover:
gcloud logging read '
resource.type="http_load_balancer" AND
jsonPayload.enforcedSecurityPolicy.name="POLICY_NAME" AND
jsonPayload.previewSecurityPolicy.matchedRulePriority:*
' --project=PROJECT_ID --limit=20Critical Gotchas and Domain Rules
evaluatePreconfiguredExpris NEVER Opt-In: The array in legacyevaluatePreconfiguredExprwas strictly an exclusion (opt-out) list. Treating it as opt-in would inadvertently disable all other signatures in that ruleset!Never Re-introduce Deprecated Signatures: All 15 retired CRS 3.0/3.3 signature numbers (
981172,981173,980130,949110; SQLi:942110; RCE:932100,932105,932106,932110,932115,932150; Scanner Detection:913101,913102,913110,913120) were removed in CRS 4.22. Keeping them inopt_out_rule_idsortargetRuleIdscauses Cloud Armor API schema rejections.Method Enforcement Defaults: CRS 4.22 Method Enforcement blocks
PUT,PATCH, andDELETE. Never perform a silent in-place upgrade of method enforcement without user confirmation.Preview Rule Priorities and Cutover Safety: Cloud Armor evaluates rules in ascending priority order (
0to2147483647). A preview rule must evaluate before the enforcing rule it previews, but after any preceding rule (PREV_PRIORITY < PREVIEW_PRIORITY < ENFORCED_PRIORITY) so it never crosses interveningallowor custom rules. During cutover to full enforcement, update the originalENFORCED_PRIORITYrule in-place to CRS 4.22 and deletePREVIEW_PRIORITYrather than promotingPREVIEW_PRIORITYin place.Atomic Import for Structured Exclusions: When a policy contains complex
preconfiguredWafConfigblocks, prefer exporting the policy JSON, transforming it, and applying it viagcloud compute security-policies importto ensure atomic updates.Preserve Standalone CVE Signatures (
cve-canary):cve-canaryis an out-of-band rule for specific vulnerabilities (for example, Log4j CVE-2021-44228 / CVE-2021-45046, React RCE CVE-2025-55182). Its signature IDs (owasp-crs-v030001-id044228-cve,id144228-cve,id244228-cve,id344228-cve) are valid and retain thev030001prefix. Only upgrade the syntax toevaluatePreconfiguredWaf('cve-canary', ...); never rewrite them tov042200or drop them as deprecated.
References and Resources
ruleset_mappings.md: Full CRS 3.0 / 3.3 to 4.22 ruleset mapping, sensitivity levels, and signature counts.
fine_tuning_and_cel.md: CEL syntax options, structured
preconfiguredWafConfigexclusions, and method enforcement mitigations.gcloud_recipes.md: Copy-pasteable
gcloudrecipes for audit, preview mode, and Cloud Logging queries.upgrade_policy.py: Deterministic CLI helper script.
contributing.md: Domain and code invariants for maintaining this skill.
Files
- ATTRIBUTION.mdAdded by AutoGineer876 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md19.2 KiB
- references/attribution.md1.9 KiB
- references/contributing.md4.3 KiB
- references/fine_tuning_and_cel.md6.7 KiB
- references/gcloud_recipes.md8.2 KiB
- references/ruleset_mappings.md11.7 KiB
- scripts/upgrade_policy.pyScript35.0 KiB
references/attribution.md
Usage Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command with
this skill, follow these usage attribution instructions. Tag every command you
execute directly in the terminal so usage can be attributed. The tag identifies
only the skill and its version; it carries no user data.
gcloudCLI Commands: Prefix everygcloudinvocation, whatever the subcommand, with the metrics environment variable. Set it inline on each command because shell state may not persist between commands:CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:cloud-armor-crs-rule-upgrader)" \ gcloud <command> [flags]Do not use
gcloud config setfor this: it would persist beyond the current task and mislabel unrelated usage.Direct HTTP, REST, and MCP Requests: On direct HTTP calls to Google Cloud APIs (for example with
curl) or HTTP requests to a remote MCP server, includeagent-skills/1.0 (skill:cloud-armor-crs-rule-upgrader)in theUser-Agentheader. If aUser-Agentheader is already specified, append this string to the end of it rather than overwriting existingUser-Agentdata — the collection pipeline parses theagent-skills/<version>andskill:<name>tokens, so any rewording breaks attribution:User-Agent: <existing_user_agent> agent-skills/1.0 (skill:cloud-armor-crs-rule-upgrader)Constraint for Generated Code: The tracking prefix is strictly for commands you execute directly in the terminal. Do NOT include this tracking prefix in generated scripts, Terraform templates, or code provided to the user for their own repositories.
User Opt-Out: If the user asks to disable or remove tracking or attribution tags, omit the
CLOUDSDK_METRICS_REQUEST_ATTRIBUTIONvariable and customUser-Agentsuffix from all commands.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs a command-line tool, Needs Python
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Publisher
- Google (Official)
- Source
- google/skills · skills/cloud/cloud-armor-crs-rule-upgrader · commit 2194d3b
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download cloud-armor-crs-rule-upgrader.zip