fix: Redact private attributes in migration op events#181
Merged
Conversation
The MigrationOpEvent serializer wrote the raw context directly, bypassing the private-attribute redaction applied to every other inline event type. Attributes marked private (context-declared, globally configured, or all-attributes-private) leaked in plaintext in the migration op event context. Serialize the migration context through the same ContextAttributes redaction path used by BaseEvent, extracted into a shared BaseEvent::redacted_context_attributes helper. Add regression tests covering global, all-private, context-declared, and anonymous redaction. Fixes SDK-2716, SEC-8527.
keelerm84
force-pushed
the
mk/sdk-2716/migration-context-redaction
branch
from
July 20, 2026 14:47
ee77408 to
456ff41
Compare
keelerm84
marked this pull request as ready for review
July 20, 2026 14:56
jsonbailey
approved these changes
Jul 20, 2026
keelerm84
pushed a commit
that referenced
this pull request
Jul 21, 2026
🤖 I have created a release *beep* *boop* --- ## [3.1.2](3.1.1...3.1.2) (2026-07-21) ### Bug Fixes * Bump MSRV from 1.94 to 1.95 ([#179](#179)) ([103afe1](103afe1)) * Redact private attributes in migration op events ([#181](#181)) ([d2e51bc](d2e51bc)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
MigrationOpEventserializer wrote the raw evaluation context directly, bypassing the private-attribute redaction applied to every other inline event type. Attributes marked private -- context-declared (_meta.privateAttributes), globally configured, or viaall_attributes_private-- were transmitted in plaintext in themigration_opevent context in the outgoing analytics payload, even though the same context was redacted in ordinary events.The privacy settings were threaded into the event but ignored at serialization time.
This serializes the migration context through the same
ContextAttributesredaction path used byBaseEvent, extracted into a sharedBaseEvent::redacted_context_attributeshelper so both serializers stay in sync. Adds regression tests covering global, all-private, context-declared, and anonymous-context redaction.Reported via BugCrowd. Verified end-to-end against the SDK contract test harness: the new migration redaction tests fail before this change (leaking the private attribute) and pass after.
Note
Medium Risk
Touches analytics payload serialization for PII/private attributes; the change reduces exposure but any event-format mistake could affect migration telemetry.
Overview
Fixes a privacy bug where
migration_opevents inlined the raw evaluationContext, so private attributes could appear in outbound analytics even when other inline events redacted them.Serialization now uses
BaseEvent::redacted_context_attributes(), shared withBaseEvent’s inline path, honoring global private attributes,all_attributes_private, context-declared private attributes, and anonymous redaction.MigrationOpEvent’s serializer switches frombase.contextto that helper. Four unit tests assert redacted_meta.redactedAttributesfor migration op payloads.Reviewed by Cursor Bugbot for commit 456ff41. Bugbot is set up for automated code reviews on this repo. Configure here.