out_stackdriver: add trust_payload_local_resource_id option#12027
out_stackdriver: add trust_payload_local_resource_id option#12027erain wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughAdds configurable trust handling for Stackdriver payload ChangesStackdriver resource attribution
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant LogPayload
participant Formatter as stackdriver_format()
participant StackdriverEntry
LogPayload->>Formatter: Provides local_resource_id and monitored-resource data
Formatter->>Formatter: Selects configured resource_type or k8s_cluster fallback
Formatter->>StackdriverEntry: Emits resource.type and resource-specific labels
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
/assign |
The logging.googleapis.com/local_resource_id field is read from the log payload to derive the k8s_container/k8s_pod/k8s_node monitored resource labels. In multi-tenant pipelines the payload is workload-controlled, so a compromised or malicious workload can forge this field and attribute its log entries to another namespace/pod/container across trust boundaries. Add a trust_payload_local_resource_id option (default: true, preserving existing behavior). When set to false: - the payload local_resource_id is ignored; resource labels are only derived from the tag (via tag_prefix + regex), configured resource_labels, or a payload monitored resource map. - when none of those trusted sources is available, entries fall back to the cluster scoped k8s_cluster resource instead of packing workload labels forged from the payload. This mirrors the hardening previously applied to the Go based logging agent in GoogleCloudPlatform/k8s-stackdriver#1186. Signed-off-by: Yu Yi <yiyu@google.com>
Cover the trust_payload_local_resource_id=false behavior: - resource_k8s_container_untrusted: a payload supplied local_resource_id with a non-matching tag falls back to the cluster scoped k8s_cluster resource and packs no workload labels. - resource_k8s_container_untrusted_tag_wins: a tag matching the default regex still resolves the full k8s_container resource; the untrusted payload value is ignored. Signed-off-by: Yu Yi <yiyu@google.com>
|
Rebased onto current master now that #12023 has merged; this PR is down to the two |
Summary
Adds a
trust_payload_local_resource_idoption (default:true, existing behavior unchanged) to the Stackdriver output.The plugin reads
logging.googleapis.com/local_resource_idfrom the log payload to derive thek8s_container/k8s_pod/k8s_nodemonitored-resource labels. In multi-tenant pipelines the payload is workload-controlled: a compromised or malicious workload can forge this field and attribute its log entries to another namespace/pod/container across trust boundaries (log-injection/forgery). The Go-based logging agent addressed the same issue in GoogleCloudPlatform/k8s-stackdriver#1186.With
trust_payload_local_resource_id false:local_resource_idis ignored; resource labels are derived only from trusted sources — the tag (tag_prefix+ regex), configuredresource_labels, or a payload monitored-resource map;k8s_clusterresource (project/location/cluster labels from plugin config) rather than packing workload-scoped labels forged from the payload.This is defense-in-depth for pipelines that currently trust the payload value; pipelines where the tag regex always resolves (e.g. standard
tail+ kubernetes setups) see no behavioral difference other than the forged value being ignored.Testing
resource_k8s_container_untrusted: payload-suppliedlocal_resource_idwith a non-matching tag falls back tok8s_clusterwith no workload labels.resource_k8s_container_untrusted_tag_wins: a tag matching the default regex still resolves the fullk8s_containerresource; the untrusted payload value is ignored.ctest -R flb-rt-out_stackdriverpasses (full suite, including the multi-worker concurrency test).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit
New Features
Bug Fixes
Tests