Skip to content

feat(flags): support obfuscated assignment keys - #1188

Open
leoromanovsky wants to merge 7 commits into
developfrom
flag-key-obfuscation
Open

leoromanovsky wants to merge 7 commits into
developfrom
flag-key-obfuscation

Conversation

@leoromanovsky

@leoromanovsky leoromanovsky commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Tracking: FFLSDK-264

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_capabilities field. Existing request fields stay unchanged.

X-DD-FEATURE-FLAGS-CAPABILITIES: assignment-encoding-flag-key-256-v1

Capabilities 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, validate obfuscation: {scheme, salt} and hash the application key for lookup. The response scheme remains flag-key-sha256-v1:

lowercase_hex(SHA256(
  UTF8("datadog.feature-flags.flag-key.v1") || 0x00 ||
  decode_hex(salt) || UTF8(application_flag_key)
))

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 Dart 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 telemetry
Loading
  • Cache up to 1,024 lookup hashes per descriptor. Do not cache flag values or change exposure deduplication.
  • Implement parsing and SHA-256 lookup in datadog_flags. The Flutter wrapper uses this Dart implementation; no native bridge change is needed.
  • Keep encoded assignments, metadata, and context together in memory and the configured store. Persist keys under encodedFlags; continue reading legacy plaintext caches.
  • Preserve evaluation calls, values, original-key telemetry, and Flutter RUM annotations.
  • Reject invalid encoding metadata without a plaintext retry. Keep same-context fallback.
  • Add no customer enablement option or SDK-version reporting changes.

Release requires edge support for the new header. This PR does not deploy backend changes.

Related: edge rollout, browser implementation.

@datadog-official

This comment has been minimized.

@leoromanovsky
leoromanovsky marked this pull request as ready for review October 5, 2026 22:19
@leoromanovsky
leoromanovsky requested review from a team as code owners October 5, 2026 22:19
@leoromanovsky
leoromanovsky requested review from danyal002 and greghuels and removed request for a team October 5, 2026 22:19
jeff-morgan-dd
jeff-morgan-dd previously approved these changes Oct 5, 2026
greghuels
greghuels previously approved these changes Oct 6, 2026
@leoromanovsky
leoromanovsky dismissed stale reviews from greghuels and jeff-morgan-dd via 7c915bf October 6, 2026 19:59

@fuzzybinary fuzzybinary left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mostly LGTM, but the README is getting quite long and quite in the weeds - it might be worth looking into splitting it out into an overview and more detailed documentation / implementation details.

import 'package:crypto/crypto.dart';
import 'package:meta/meta.dart';

const supportedFlagsCapabilities = ['assignment-encoding-flag-key-256-v1'];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be an enum, in case we want to add new ones later?

FlagKeyObfuscation._(this.salt);

/// Validates the wire fields, including explicitly null fields.
static FlagKeyObfuscation? fromSnapshot(Map<String, Object?> json) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this library not use json_serializable?

Encoded snapshots use `encodedFlags` and store their encoding descriptor.
Existing plaintext snapshots remain readable.
Older SDKs cannot use an encoded snapshot after a downgrade. They return defaults
until a normal plaintext network response provides assignments.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README in flutter package is public facing documentation for users. Some of this appears to be more for implementation details for maintainers. I'm fine retaining that information in the repo, but we should really find a better place for it.

Comment thread LICENSE-3rdparty.csv
Comment on lines -42 to +44
test,test_fonts,BSD-3-Clause,"Copyright 2019-2020 eBay Inc." No newline at end of file
test,test_fonts,BSD-3-Clause,"Copyright 2019-2020 eBay Inc."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the tool that generates this remove the newline here? If so I'll look into fixing it.

@linear-code

linear-code Bot commented Oct 8, 2026

Copy link
Copy Markdown

FFLSDK-264

@barboraplasovska
barboraplasovska removed their request for review October 9, 2026 13:39
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.

4 participants