Skip to content

Match Prebid consent hash formats - #1738

Draft
prk-Jr wants to merge 3 commits into
fix/1686-gpp-applicable-sectionsfrom
fix/1736-prebid-cst-hash-format
Draft

prk-Jr wants to merge 3 commits into
fix/1686-gpp-applicable-sectionsfrom
fix/1736-prebid-cst-hash-format

Conversation

@prk-Jr

@prk-Jr prk-Jr commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Match the SharedID _cst companion to the publisher's Prebid.js hash format, so matching consent does not make Prebid replace the server's cookie after navigation.
  • Add [integrations.prebid].consent_hash_format with legacy (default), with-coppa, with-addtl-consent, and with-null-hash. Resolve it once at startup and reject unknown names instead of silently falling back.
  • Preserve Hash the CMP's applicable GPP sections in the SharedID _cst cookie #1735's raw GPP applicable-section hashing, including sentinels, and document the unsupported AC, GCM, and non-default COPPA cases.

Stacked on #1722 (fix/1686-gpp-applicable-sections), starting at 80d1ee52f, which contains the #1735 fix. This PR targets that branch. Its existing US-geolocation review concern remains outside this change.

Design and behavior

The server previously always used the Prebid 10.26 format. Publishers can now select the format their external bundle uses:

Setting Prebid.js versions TCF fields Disabled-COPPA contribution Handler without data
legacy Through 11.13 GDPR scope, TC string Literal 0 Hash of JSON null
with-coppa 11.14–11.40 GDPR scope, TC string Hash of JSON false Empty string
with-addtl-consent 11.41–11.53 GDPR scope, TC string, AC Hash of JSON false Empty string
with-null-hash 11.54 onward GDPR scope, TC string, AC Hash of JSON false Hash of JSON null

A "handler without data" is a TCF, US Privacy, or GPP consent handler whose module is absent from the bundle or which resolved no consent. Prebid.js 11.14 replaced the consent handler class with a factory whose resolve sets the cached hash's dirty flag to whether the data changed. A handler without data is resolved before userId first reads allConsent.hash; its data never changes from the initial null, so the cached hash stays unset and Array.join contributes an empty string. Prebid.js 11.54 changed the flag to dirty || changed, restoring the hash of JSON null. A fingerprint of the hash-relevant lines of every 11.x tag shows exactly these four regimes.

A named format selects the behavior directly without maintaining a version parser. The default preserves existing vectors and matches the locked Prebid 10.26.0 bundle; ^10.26.0 excludes 11.x. Selecting a newer format changes the companion hash, including on requests without TCF, without changing consent enforcement or identity eligibility.

Tagged-source reproduction uncovered a COPPA change at 11.14.0 and the handler-caching change above. With the existing test TC string and no other consent signals, tagged outputs are:

Tagged behavior _cst
10.26 through 11.13 FpjVEA==
11.14 through 11.40 S0Rasw==
11.41 through 11.53, no AC kH3xXg==
11.54 onward, no AC or enabled GCM rW19lA==
11.54 onward, AC reference 2~1.2~dv. efIszA==

The issue's IuPFqQ== and 2Bt6SA== also reproduce, but only when the new TCF field list retains the legacy literal COPPA contribution. They are isolated field-change vectors rather than stock cookie hashes.

These values were computed in a throwaway Node 24 script from the tagged cyrb53Hash, consent handler hash caching for each regime, and User ID's getConsentHash cookie encoding. Tagged 11.13 and 11.14 establish the COPPA and caching boundary; 11.41 establishes the third TCF field; 11.54 restores the null hash and adds the opt-in GCM handler. The legacy and 11.54 results reproduce every earlier vector unchanged. Combined TCF/GPP sentinel vectors were reproduced for all four formats too.

Known mismatches

  • Nonempty CMP addtlConsent: request transport remains deferred; with-addtl-consent and with-null-hash hash null when no AC is available. EC-POST-only transport would lose AC on the next navigation.
  • Enabled Prebid GCM (11.54+): its extra handler is not transported to the server.
  • Publisher coppa = true: the server formats assume disabled COPPA.

Changes

File Change
crates/trusted-server-core/src/integrations/prebid.rs Typed format setting, legacy default, parsing tests.
crates/trusted-server-core/src/ec/app.rs Fallible startup resolution and configuration tests.
crates/trusted-server-core/src/ec/app/lifecycle.rs Carry the selected format into request-local write-back.
crates/trusted-server-core/src/ec/sharedid.rs Select TCF/COPPA/empty-handler hashing; preserve legacy and GPP behavior.
crates/trusted-server-core/src/ec/app/route_tests.rs Distinct TCF hashes through real application write-back and cookie replay.
crates/trusted-server-core/src/test_support.rs Scoped native lint allowance for the existing full-response error contract; no behavior change.
trusted-server.example.toml Document the setting and limits.
docs/guide/integrations/prebid.md Format/version mapping and known mismatches.
docs/guide/edge-cookies.md SharedID compatibility guidance.
docs/superpowers/specs/2026-12-04-1736-prebid-cst-hash-design.md Design, upstream evidence, and three review rounds.
docs/superpowers/plans/2026-12-04-1736-prebid-cst-hash.md Implementation and verification record.

Closes

Closes #1736

Spec

Spec: Configurable Prebid consent hash format

Test plan

Targeted local checks used Rust 1.98.1 and Node 24.20.0. GitHub Actions will run the remaining gates; the full CI suite was not run locally.

  • Native core library: 4003 passed, 2 ignored. Configuration, tagged hashes for all four formats, GPP sentinels, startup rejection, disabled-integration semantics and EC POST cookie replay are covered. Disabling the empty-handler contribution fails the unit, GPP and application write-back vectors.

  • cargo test-axum: 147 passed, 4 ignored.

  • Core native clippy --all-targets --all-features -- -D warnings, cargo clippy-axum and cargo clippy-fastly passed. The inherited result_large_err failure was first reproduced on the exact base, then addressed with a scoped test-helper allowance.

  • cargo fmt --all -- --check; changed-document Prettier, whitespace, and changed-line domain checks passed.

  • Core documentation built; 31 warnings remain.

  • Axum runtime verification of the first commit with geo-cloudfront, a controlled local origin, synthetic protected GB ingress, fresh consented TCF, and real prepared record storage: the server emitted the configured format, a second navigation left matching SharedID and companion cookies untouched, and omitting the setting returned legacy hashes. The corrected intermediate vectors are covered through the same application write-back and cookie replay in ec_route_uses_configured_consent_hash_format_without_rewriting_matching_cookies. No browser was run.

  • Fastly/Cloudflare/Spin runtime and WASM gates: left to CI.

  • Full JS and documentation suites: left to CI.

Checklist

  • Spec linked above, with three review rounds.
  • Changes follow AGENTS.md conventions.
  • No unwrap() in production code.
  • Uses existing logging conventions.
  • New behavior has tests.
  • No secrets or credentials committed.

@prk-Jr prk-Jr self-assigned this Dec 4, 2026
@prk-Jr
prk-Jr added this pull request to stack #1731 December 4, 2026 13:34
@prk-Jr prk-Jr linked an issue Dec 4, 2026 that may be closed by this pull request
3 tasks
prk-Jr and others added 2 commits December 4, 2026 20:00
Prebid.js 11.14 through 11.53 resolve a consent handler without data
before userId first reads its hash, which leaves the cached hash unset,
so the combined hash joins an empty string for it. 11.54 restored the
hash of JSON null. The newer formats hashed null for every release, so a
TCF-only page on 11.14 through 11.53 still had its companion rewritten.

Make with-coppa and with-addtl-consent contribute an empty string for a
handler without data, narrow with-addtl-consent to 11.41 through 11.53,
and add with-null-hash for 11.54 onward. Recompute the unit, GPP and
application write-back vectors and update the guides and spec.
@aram356

aram356 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Merged #1614's /_ts/ local answers (48930c270) into this branch as 736569310, on top of 7f8a1ff0f.

Trusted Server owns the /_ts/ namespace (#1740). A request for /_ts or any /_ts/ path that no route handles now gets a local 404 on Fastly, Axum, Cloudflare and Spin, and never reaches the publisher origin. The path is matched after percent-decoding. Paths outside the namespace, such as /_tsx or /articles/_ts/x, still go to the publisher origin, and every routed /_ts/ path answers as before.

This merge takes #1722's new head (b0745b200), which carries 48930c270 and nothing else new to this branch. It was clean.

Checks on this head: no conflict markers; cargo fmt --all -- --check passes; the merge adds exactly #1614's change to this branch's files; it merges cleanly with every lower head in its stack; clippy-fastly, clippy-axum, clippy-cloudflare and clippy-spin-native pass. rc/identity (e72407155) passed the full CI gate list with the change.

This branch has not been deployed

No deployments
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.

Match the _cst consent hash of Prebid.js 11.41 and later

2 participants