Cloud Armor, security posture and SIEM log export for PCSE: block L7 attacks, catch drift

13 min read

The Professional Cloud Security Engineer exam has three items that sit in two different sections but often show up together in real operations: 2.1 (section 2, ~22%) covers web application firewalls such as Google Cloud Armor; 4.1 (section 4, ~19%) covers managing policy and drift detection at scale (cloud security posture management, custom organization policies and custom modules for Security Health Analytics); and 4.2 covers exporting logs to external security systems with log sinks and aggregated sinks. The newest questions in the bank's free preview land right on these three points. This post walks through how each tool works, with gcloud commands, config files, a decision table and example questions. For the exam format and scope, see the PCSE study guide; VPC Service Controls, Cloud KMS, Sensitive Data Protection and advanced IAM are covered in the VPC SC, KMS, SDP and IAM controls post.

Key takeaways

  • SQL injection and XSS: a Cloud Armor security policy with preconfigured WAF rules plus your own custom rules, attached to the load balancer's backend service; Adaptive Protection handles HTTP floods and doesn't replace the WAF.
  • Test the WAF before blocking: use --preview and start at sensitivity 1; by default Cloud Armor runs at sensitivity 4, which is more likely to block real users.
  • To both prevent and detect misconfigurations against industry and internal standards: a security posture (organization policies + Security Health Analytics detectors) deployed on the folder; it needs Security Command Center Premium activated at the organization level.
  • Workspace sign-in logs to a SIEM in near real time: an organization-level aggregated sink to Pub/Sub, with roles/pubsub.publisher granted to the sink's writer identity.

Three jobs in security operations: block, stay compliant, watch

  • Block attacks as they arrive. For a public web app, common attacks happen at layer 7 (the content of the HTTP request): SQL injection (putting SQL into a parameter to read the database) and cross-site scripting, or XSS (injecting a script into a page so it runs in other people's browsers). Tool: Cloud Armor.
  • Keep configuration on standard. Stop forbidden configurations up front, and detect anything that has moved away from the standard (called drift). Tool: security posture in Security Command Center (SCC).
  • See what is happening. Security teams often use a third-party SIEM (Security Information and Event Management, a system that collects logs and looks for signs of attack). Google Cloud's job is to get logs there quickly and completely. Tool: Cloud Logging with sinks.

The exam likes to mix these jobs with "almost right" options: a network firewall instead of a WAF, organization policies alone when the question also asks for detection, or logs written to Cloud Storage when the question asks for near real time. Knowing which layer each tool works at lets you rule those out.

Cloud Armor: a WAF for SQL injection and XSS

Where a security policy attaches

Cloud Armor works through security policies: an ordered list of rules applied to requests headed for a protected resource. A policy attaches to a load balancer's backend service (edge security policies can also attach to backend buckets). The docs state that preconfigured WAF rules can only be used with backend services behind a load balancer. Supported types include all external Application Load Balancers (classic included), the regional internal Application Load Balancer, the global external proxy Network Load Balancer and a few others; with external load balancers, rules run at the edge of Google's network, before traffic enters your VPC.

So "attach the policy at the load balancer" and "at the backend service" in the options are really the same place. What you need to compare is the content of the policy.

Preconfigured WAF rules and sensitivity

Preconfigured WAF rules are ready-made rule sets built from the OWASP ModSecurity Core Rule Set (CRS), each with dozens of signatures (attack detection patterns). The docs currently recommend CRS 4.22, for example sqli-v422-stable and xss-v422-stable; 3.3 is still supported and 3.0 should be avoided. Each set has a stable and a canary version (the latest one, for testing changes).

Each signature has a sensitivity level from 1 to 4, matching the OWASP paranoia level. Low levels are high-confidence signatures with few false positives; high levels catch more but are more likely to block real users. If you don't set it, Cloud Armor runs at level 4 and evaluates every signature. The docs recommend starting at level 1 in preview mode and raising it step by step.

gcloud compute security-policies create web-waf \
  --description="WAF for the web app"

EXPR="evaluatePreconfiguredWaf('sqli-v422-stable',\
 {'sensitivity': 1})"

gcloud compute security-policies rules create 1000 \
  --security-policy=web-waf \
  --expression="$EXPR" \
  --action=deny-403 --preview

gcloud compute backend-services update web-backend \
  --security-policy=web-waf --global

Do the same with xss-v422-stable at another priority. Rules are evaluated by priority from the lowest number up, from 0 to 2147483646; 2147483647 is reserved for the default rule (applied when nothing else matches). Leave gaps (1000, 2000…) so you can insert rules later.

Custom rules and preview mode

Preconfigured rules only catch generic attack patterns. A real application also needs custom rules: block by path, header, country (origin.region_code) or IP range, or allow internal clients first. That is why "customized and pre-configured WAF rules" beats "only enable pre-configured WAF rules" when the question says the attacks are "sophisticated" and you must minimize impact on legitimate traffic: both phrases call for tuning.

Tuning relies on preview mode: a rule in preview doesn't block; it only records the result in logs and Cloud Monitoring, and Cloud Armor keeps evaluating the other rules. Preview rules are still charged per request. If a signature blocks real traffic, opt it out, or exclude a request field from inspection; once you exclude fields, you can't use the allow action with that rule.

Real limits to know: Cloud Armor inspects at most the first 64 kB of the request body; URL-encoded and JSON bodies are decoded before rules apply, while other types are inspected as raw data; WAF rule changes typically take several minutes to propagate.

How Adaptive Protection, rate limiting and firewalls differ from a WAF

Adaptive Protection uses machine learning to detect layer 7 DDoS attacks such as HTTP floods (huge numbers of requests meant to take a service down). You enable it per policy (--enable-layer7-ddos-defense on gcloud compute security-policies update); it needs at least an hour to learn a baseline, then sends alerts with an attack signature and a suggested rule. Full alerts require Cloud Armor Enterprise; otherwise you get only a basic alert. Creating a new policy means retraining the baseline, so don't create new policies in the middle of an attack.

Rate limiting caps requests per client: throttle drops the part above the threshold, while rate_based_ban blocks the client for a period. A rate-based ban rule can't be changed back to throttle (the other direction works). Example with illustrative numbers:

gcloud compute security-policies rules create 2000 \
  --security-policy=web-waf --src-ip-ranges="*" \
  --action=rate-based-ban \
  --rate-limit-threshold-count=100 \
  --rate-limit-threshold-interval-sec=60 \
  --ban-duration-sec=600 \
  --conform-action=allow --exceed-action=deny-429 \
  --enforce-on-key=IP

Neither one recognizes a single SQL injection request, because that request is neither numerous nor unusual in volume. Blocking known bad IPs with /32 Cloud Next Generation Firewall rules only stops old sources too; the attacker switches IPs, and an IP-based rule doesn't look at the HTTP payload.

Security posture: prevent and detect misconfigurations per folder

What a posture contains

Security posture is the SCC service for defining, deploying and monitoring a security standard. A posture holds one or more policy sets, and each policy set holds policies of two kinds:

  • Preventive: organization policy constraints, custom constraints included. Example: forbid VMs with public IPs, so a create call with the wrong config is rejected.
  • Detective: Security Health Analytics (SHA) detectors, custom modules included. A misconfigured resource becomes a finding in SCC.

Why both? The docs say applying new organization policies is "usually not retroactive": resources created wrong earlier stay as they are. Custom constraints are checked only on the methods listed in methodTypes (for example CREATE). SHA fills the gap by scanning (on Premium, batch scans run every day, and some detectors scan as soon as a configuration changes) and creating findings.

After deployment, SCC monitors drift: if someone changes a policy within the posture's scope so it no longer matches the definition, SCC creates a finding you can review, filter, resolve and export like any other finding.

Templates, YAML and the deploy commands

Templates are available: secure_by_default_essential, cis_2_0 (CIS Benchmark v2.0.0), nist_800_53, iso_27001, pci_dss_v_3_2_1, plus templates for AI, BigQuery, Cloud Storage and VPC. The essential versions can be deployed as is; the extended ones must be customized first. A common approach: take the YAML for your industry template, then add your internal policies in a separate policy set.

description: Folder for regulated workloads
state: ACTIVE
policySets:
- policySetId: internal-baseline
  policies:
  - policyId: Require OS Login
    constraint:
      orgPolicyConstraint:
        cannedConstraintId: compute.requireOsLogin
        policyRules:
        - enforce: true
  - policyId: API Key Exists
    constraint:
      securityHealthAnalyticsModule:
        moduleName: API_KEY_EXISTS
        moduleEnablementState: ENABLED

Create the posture and deploy it on the folder (IDs are examples):

ORG=organizations/123456789012/locations/global

gcloud scc postures create \
  $ORG/postures/regulated-posture \
  --posture-from-file=posture.yaml

gcloud scc posture-deployments create \
  $ORG/postureDeployments/regulated-folder \
  --posture-name=$ORG/postures/regulated-posture \
  --posture-revision-id=REVISION_ID \
  --target-resource=folders/987654321

Rules and limits worth remembering:

  • It needs SCC Premium (or Enterprise, a deprecated tier that shuts down on 21 May 2027) activated at the organization level; with a project-level activation you can't use postures.
  • You can deploy only one posture per organization, folder or project. Postures are inherited downward; when two levels define a policy differently, the lower level wins.
  • Only an ACTIVE revision can be deployed. Limits: 100 postures and 1000 deployments per organization, 400 policies per posture.
  • Custom constraints must be defined inside the posture file; a constraint you created in the console can't be reused. This is a common real-world mistake.

Compared with custom organization policies, Assured Workloads and Workload Manager

  • Custom organization policies alone: prevent misconfigurations at create or update time, but don't detect what is already wrong and don't track drift. If the question says "prevent and detect", that covers only half.
  • Assured Workloads: a folder with a control package for a specific compliance regime (data location, support personnel and so on). It fits when the question names a regime, but it isn't where you write internal company policies.
  • Workload Manager: evaluates workloads against best practices, lets you write rules in Rego (the Open Policy Agent policy language) stored in Cloud Storage, runs scheduled evaluations and can export results to BigQuery. It evaluates and reports; it can't block a create call with a bad configuration.

Exporting logs to a SIEM: aggregated sink to Pub/Sub

Getting Workspace logs into Cloud Logging

Google Workspace sign-in logs (Login Audit) don't appear in Google Cloud by themselves. You must enable sharing Google Workspace data with Google Cloud in the Google Admin console. Once enabled, Google Cloud receives all Workspace audit logs (Admin, Enterprise Groups, Login, OAuth Token, SAML); to drop some of them, use exclusion filters on sinks.

These are organization-level logs, not tied to any project. Login Audit writes Data Access audit logs only, with protoPayload.serviceName="login.googleapis.com" and event names such as login_success, login_failure and logout. Try it in the Logs Explorer at the organization level:

protoPayload.serviceName="login.googleapis.com"
protoPayload.metadata.event.eventName="login_failure"

Creating the sink and granting access

The docs say Workspace logs must be routed with an organization-level aggregated sink, to Cloud Storage, Pub/Sub or BigQuery. Add --include-children to also collect logs from child folders and projects.

FILTER='protoPayload.serviceName="login.googleapis.com"'

gcloud logging sinks create siem-auth \
  pubsub.googleapis.com/projects/sec-logs/topics/siem \
  --organization=123456789012 --include-children \
  --log-filter="$FILTER"

gcloud logging sinks describe siem-auth \
  --organization=123456789012 \
  --format='value(writerIdentity)'

gcloud pubsub topics add-iam-policy-binding siem \
  --project=sec-logs --member=WRITER_IDENTITY \
  --role=roles/pubsub.publisher

gcloud pubsub subscriptions create siem-sub \
  --topic=siem --project=sec-logs

In practice the filter is longer (Google Cloud audit logs, Cloud Armor logs and so on), joined with OR. The SIEM reads from the subscription. The step people forget most: the sink writes as its own service account (the writer identity); without roles/pubsub.publisher on the topic, the sink exists but writes nothing.

Limits from the docs: up to 200 sinks per folder or organization; filters up to 20,000 characters; sink changes can take a few minutes to apply; aggregated sinks can't write to Pub/Sub topics with in-transit restrictions; if the destination is inside a VPC Service Controls perimeter, you need an ingress rule for the sink's service account.

Why not Cloud Storage or polling

  • Sink to Cloud Storage: logs are written to the bucket in hourly batches, so it doesn't meet "near real-time". Good for long-term storage, not for attack detection.
  • Running gcloud logging read on a schedule: that's a homemade polling job, delayed by its interval, prone to missed or duplicate events when the job fails, and work to run. A sink to Pub/Sub pushes logs as soon as they reach Cloud Logging.
  • Workspace sending straight to the SIEM's API: the docs on sharing Workspace logs describe the path through Cloud Logging and routing with sinks; going direct gives you no single place that also collects Google Cloud logs.

Decision table: pick the tool from the question's requirement

Requirement in the questionChooseNotes / why other options fail
SQL injection, XSS, OWASP Top 10 on a web app behind a load balancerCloud Armor security policy: preconfigured WAF rules + custom rulesIP firewalls don't inspect the payload; Adaptive Protection is for L7 DDoS
HTTP floods, unusual request volumeAdaptive Protection + rate limitingFull signatures and suggested rules need Cloud Armor Enterprise
Test new rules without blocking real usersPreview mode, low sensitivity first, then raise itPreview rules are still charged
Prevent and detect misconfigurations on a folder, against industry and internal standardsSecurity posture (org policies + SHA, predefined and custom) deployed on the folderOrg policies alone lack detection; Workload Manager doesn't block
Only block one kind of configuration at create timeOrganization policy, tested with dry runNo SCC Premium needed
Workload must follow a specific compliance regimeAssured WorkloadsDoesn't replace a posture for internal policies
Workspace and Google Cloud logs to a SIEM in near real timeOrganization-level aggregated sink to Pub/SubCloud Storage writes hourly batches; polling is delayed and fragile
Keep logs long term at low costSink to Cloud StorageNo real-time need

Common traps

  • Scenario: Google Workspace, Google Cloud and a third-party SIEM; you must export successful and failed sign-in events to the SIEM in near real time. Answer: a Cloud Logging sink to a Pub/Sub topic that the SIEM subscribes to; polling with gcloud logging read and a Cloud Storage bucket both miss the timing requirement. See practice question #356.
  • Scenario: a web app faces increasingly sophisticated XSS and SQL injection, and you must minimize impact on legitimate traffic. The traps are "load balancer + Adaptive Protection + throttling" (flood protection) and "block /32 IPs with Cloud NGFW" (only known sources). The strongest option is a security policy with both custom rules and preconfigured WAF rules, attached at the load balancer.
  • Scenario: a folder in a regulated industry must prevent and detect misconfigurations against industry and internal policies. The traps are "custom organization policies only" (prevent only), "Assured Workloads" (no internal policies) and "Workload Manager with Rego" (evaluation only). A posture with org policies and SHA, predefined and custom, deployed on the folder covers all three.
  • Scenario: creating a project-level sink to get Workspace sign-in logs. A project sink can't see organization-level logs.
  • Scenario: the sink exists but the SIEM receives nothing. Usually roles/pubsub.publisher wasn't granted to the writer identity, or Workspace data sharing isn't enabled.

Reading the question

  • Layer 7, XSS, SQL injection, OWASP Top 10: Cloud Armor WAF. Add sophisticated or minimizing impact on legitimate traffic and prefer the option that includes custom rules.
  • DDoS, HTTP flood, anomalous traffic: Adaptive Protection and rate limiting.
  • Prevent and detect misconfigurations, drift, industry and internal policies: security posture. Only prevent: organization policies are enough.
  • Real time, near real-time, SIEM: sink to Pub/Sub. Archive, lowest cost: Cloud Storage.

Start practicing

Try 60 free Professional Cloud Security Engineer questions, then a timed exam (Pro). For an overview of the five exam sections, see the PCSE study guide.

Official sources