Skip to content

fix: Redact private attributes in migration op events#181

Merged
keelerm84 merged 1 commit into
mainfrom
mk/sdk-2716/migration-context-redaction
Jul 21, 2026
Merged

fix: Redact private attributes in migration op events#181
keelerm84 merged 1 commit into
mainfrom
mk/sdk-2716/migration-context-redaction

Conversation

@keelerm84

@keelerm84 keelerm84 commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

The MigrationOpEvent serializer 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 via all_attributes_private -- were transmitted in plaintext in the migration_op event 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 ContextAttributes redaction path used by BaseEvent, extracted into a shared BaseEvent::redacted_context_attributes helper 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_op events inlined the raw evaluation Context, so private attributes could appear in outbound analytics even when other inline events redacted them.

Serialization now uses BaseEvent::redacted_context_attributes(), shared with BaseEvent’s inline path, honoring global private attributes, all_attributes_private, context-declared private attributes, and anonymous redaction. MigrationOpEvent’s serializer switches from base.context to that helper. Four unit tests assert redacted _meta.redactedAttributes for migration op payloads.

Reviewed by Cursor Bugbot for commit 456ff41. Bugbot is set up for automated code reviews on this repo. Configure here.

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
keelerm84 force-pushed the mk/sdk-2716/migration-context-redaction branch from ee77408 to 456ff41 Compare July 20, 2026 14:47
@keelerm84
keelerm84 marked this pull request as ready for review July 20, 2026 14:56
@keelerm84
keelerm84 requested a review from a team as a code owner July 20, 2026 14:56
@keelerm84
keelerm84 merged commit d2e51bc into main Jul 21, 2026
24 checks passed
@keelerm84
keelerm84 deleted the mk/sdk-2716/migration-context-redaction branch July 21, 2026 13:57
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants