Repository navigation
Add keyed hmac256 mask strategy (CDC_MASK_HMAC_KEY) - #11
Merged
Merged
Conversation
The plain sha256 mask is deterministic but unkeyed, so low-entropy PII (emails, phone numbers, SSNs) can be recovered by hashing candidate values and comparing digests. hmac256 is HMAC-SHA256 keyed with the new CDC_MASK_HMAC_KEY env var: still deterministic — masked columns remain joinable across events and sinks — but useless to an attacker without the key. - transform: Options carries the key; CompileWithOptions threads it to strategy resolution. Using hmac256 without the key fails at startup, like every other transform misconfiguration. - config: load CDC_MASK_HMAC_KEY; wire it through newSinks. - Tests: determinism, key-dependence, divergence from unkeyed sha256, and the missing-key compile error. - Docs: README (features, env table, transforms section, key-rotation caveat), CLAUDE.md, sinks.example.yaml. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019dEj24Ta2o9QxzW9ZrSPtb
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.
What does this PR do?
Adds an
hmac256mask strategy to the declarative transforms, closing a real weakness in the existingsha256mask: an unkeyed hash of low-entropy PII (emails, phone numbers, SSNs) can be reversed by hashing candidate values and comparing digests.hmac256is HMAC-SHA256 keyed with a newCDC_MASK_HMAC_KEYenv var — still deterministic, so masked columns keep joining and deduping across events and sinks, but useless to an attacker without the key.Details:
transform.Optionscarries the key; the newCompileWithOptionsthreads it into strategy resolution (Compilekeeps its old signature for keyless use).hmac256in any transform withoutCDC_MASK_HMAC_KEYset fails at startup with an error naming the env var — consistent with how bad CEL expressions and unknown strategies already behave.config.Loadand wired throughnewSinks.Type of change
Checklist
go test ./...passes (including-race)gofmt/go vetare cleansha256, missing-key compile error)README.md/CLAUDE.mdupdated if env vars or behavior changed (env table, transforms section,sinks.example.yaml)Notes for the reviewer
sha256behavior is unchanged;hmac256is opt-in per column, so nothing shifts under current configs.🤖 Generated with Claude Code
https://claude.ai/code/session_019dEj24Ta2o9QxzW9ZrSPtb
Generated by Claude Code