Skip to content

fix(plugins/gcpaudit): route gcp.policyDelta by IAM proto, not gcs_bucket allowlist#1355

Open
raajheshkannaa wants to merge 1 commit into
falcosecurity:mainfrom
raajheshkannaa:fix/gcpaudit-policydelta-resource-types
Open

fix(plugins/gcpaudit): route gcp.policyDelta by IAM proto, not gcs_bucket allowlist#1355
raajheshkannaa wants to merge 1 commit into
falcosecurity:mainfrom
raajheshkannaa:fix/gcpaudit-policydelta-resource-types

Conversation

@raajheshkannaa
Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area plugins

What this PR does / why we need it:

Before this change, `gcp.policyDelta` only returned the correct value for `gcs_bucket` resources. Every other resource type fell through to `protoPayload.metadata.datasetChange.bindingDeltas`, which only exists on BigQuery `dataset.setIamPolicy` events. `project`, `folder`, `organization`, `service_account`, and any other GCP resource that uses the generic IAM SetIamPolicy flow returned an empty field, breaking Falco rules that match on `%gcp.policyDelta`.

The generic IAM proto (`google.iam.v1.PolicyDelta`) is emitted under `protoPayload.serviceData.policyDelta.bindingDeltas` for every service that uses the shared IAM `SetIamPolicy` endpoint. BigQuery is the documented outlier and emits its deltas under `protoPayload.metadata.datasetChange` as part of `BigQueryAuditMetadata`.

Route `bigquery_dataset` explicitly to the `metadata.datasetChange` path and default every other resource type to the `serviceData.policyDelta` path. This matches both the reporter's description ("the else path is really only used by `bigquery_dataset` type") and the published GCP audit log schema, and it stays correct for any future IAM-using resource type without further code changes.

Routing is extracted into a `policyDeltaPath` helper so the policy is unit-testable. The `gcpaudit` package had no test file before this change.

Test:

Added `extract_test.go` with 8 cases asserting the path for `gcs_bucket`, `project`, `folder`, `organization`, `service_account`, an unknown resource type, an empty string (all serviceData), and `bigquery_dataset` (datasetChange).

Which issue(s) this PR fixes:

Fixes #1351

Special notes for your reviewer:

The reporter suggested an additive fix (add the new resource types to the existing `gcs_bucket` allowlist). I inverted the default instead so unenumerated resource types like `gae_app`, `pubsub_topic`, etc. resolve correctly. The behavior change for unenumerated resources moves them from returning empty (current bug) to the generic IAM path (expected per GCP docs).

`gofmt` reports one whitespace nit on `extract.go` line 173 (`req.SetValueOffset(sdk.PluginEventPayloadOffset + uint32(...))`). This is pre-existing on upstream/main at `5855f3e`, not introduced by this PR. Happy to fold a gofmt fix in if you'd prefer.

Does this PR introduce a user-facing change?:

```release-note
fix(plugins/gcpaudit): `gcp.policyDelta` now resolves for project, folder, organization, service_account, and other IAM resource types instead of returning empty.
```

…cket allowlist

Before, gcp.policyDelta sent every resource type except gcs_bucket
through protoPayload.metadata.datasetChange.bindingDeltas. That path
only exists for BigQuery dataset.setIamPolicy. Every other GCP IAM
SetIamPolicy event emits the deltas under
protoPayload.serviceData.policyDelta.bindingDeltas (the generic
google.iam.v1.PolicyDelta proto), so project, folder, organization,
service_account, and any future IAM-using resource type returned an
empty field, breaking rules that match on %gcp.policyDelta.

Route bigquery_dataset to the metadata.datasetChange path and default
every other resource type to the generic serviceData.policyDelta
path. This matches both the GCP audit log schema and the reporter's
description ("the else path is really only used by bigquery_dataset
type"). Unknown future resource types now resolve correctly without
another code change.

Extract the routing into a small policyDeltaPath helper so the policy
is unit-testable; the gcpaudit package previously had no tests.

Closes falcosecurity#1351

Signed-off-by: Raajhesh Kannaa Chidambaram <[email protected]>
@poiana
Copy link
Copy Markdown
Contributor

poiana commented May 17, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: raajheshkannaa
Once this PR has been reviewed and has the lgtm label, please assign ahmedameenaim for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana requested review from ahmedameenaim and irozzo-1A May 17, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(gcpaudit) gcp.policyDelta: add additional resource types

2 participants