Repository navigation
Support obfuscated feature flag assignment keys - #3267
leoromanovsky wants to merge 7 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b2b5bcae5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fad1e1def8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
sameerank
left a comment
There was a problem hiding this comment.
Close to approval! One potential issue with the cache fallback that seems worth fixing
maxep
left a comment
There was a problem hiding this comment.
The behavior looks right to me. I think the Codable part can be simpler and closer to standard Swift, though. I rebuilt the obfuscation model as a sample, and it passes the shared hash vectors and the invalid-metadata cases from FlagKeyObfuscationTests. Suggestions are inline.
Tracking: FFLSDK-260
Motivation
Readable flag keys can reveal upcoming features. Support obfuscated assignments without changing application evaluation calls.
This reduces readable names in payloads; it does not hide values or prevent dictionary guessing. It is not encryption or response signing.
Changes and Decisions
Advertise support through this header instead of a JSON
supported_capabilitiesfield. Existing request fields stay unchanged.X-DD-FEATURE-FLAGS-CAPABILITIES: assignment-encoding-flag-key-256-v1Capabilities are sorted and comma-separated. They describe support, not a requirement. The edge still selects plaintext or obfuscated responses through its rollout.
For
obfuscated: true, validateobfuscation: {scheme, salt}and hash the application key for lookup. The response scheme remainsflag-key-sha256-v1:The public salt contains 16 bytes, encoded as 32 lowercase hexadecimal characters. Keys use exact UTF-8 bytes without normalization.
sequenceDiagram participant App participant SDK as iOS Flags client participant Edge as Fastly SDK->>Edge: Precompute request + capability header Edge-->>SDK: Plaintext, or encoded keys + scheme + salt SDK->>SDK: Validate and retain assignments with encoding App->>SDK: Evaluate original flag key SDK->>SDK: Hash lookup key only for encoded assignments SDK-->>App: Original value and evaluation details SDK->>SDK: Keep original flag key in telemetrynilfrom the previewsnapshot()API for encoded assignments. Key-based evaluation and original-key telemetry continue to work.Release requires edge support for the new header. This PR does not deploy backend changes.
Related: edge rollout, browser implementation.
Note
Medium Risk
Touches core Flags fetch, cache, and lookup paths with new wire format and versioned storage; mis-handling could break evaluation or leak obfuscated keys via snapshot, though behavior is gated to iOS and heavily tested.
Overview
Adds obfuscated flag keys for precomputed assignments so wire and disk payloads can use SHA-256 digests while apps still evaluate with the original key names.
Native iOS clients advertise
assignment-encoding-flag-key-256-v1viaX-DD-FEATURE-FLAGS-CAPABILITIESon precompute requests. Responses withobfuscated: truecarry scheme/salt metadata; the SDK validates keys, hashes lookups with CryptoKit, and keeps evaluation, exposure, and RUM telemetry on the plaintext key. Bridge sources (e.g. React Native) do not advertise the capability and reject encoded network or cached data.Persistence stores obfuscation metadata with assignments using data-store version 2; legacy plaintext caches still load. The preview
snapshot()API returnsnilwhen keys are encoded so exports do not leak digests. Invalid encoding metadata fails closed without a plaintext fallback, with stale cache only when the evaluation context still matches.Reviewed by Cursor Bugbot for commit 1dee5a0. Bugbot is set up for automated code reviews on this repo. Configure here.