Skip to content

Keep the EC out of bid request IDs and gate user.id on EID consent - #1709

Open
prk-Jr wants to merge 1 commit into
mainfrom
fix/1707-ec-out-of-bid-request-ids
Open

prk-Jr wants to merge 1 commit into
mainfrom
fix/1707-ec-out-of-bid-request-ids

Conversation

@prk-Jr

@prk-Jr prk-Jr commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • A reader who granted TCF Purpose 1 (storage) but refused Purpose 4 (personalized ads) had their EC sent to every Prebid Server bidder and to APS. The server-side auction and /_ts/page-bids put it in the bid request id as ts-<EC>, and every auction path set user.id to the EC whenever EC creation was allowed (Purpose 1 alone under GDPR). Prebid Server can clear user.id for a bidder, but never touches id, and APS does not go through Prebid Server.
  • The request id is now always ts-req-<random>, and user.id carries the EC only under the rule that already gates partner EIDs (allows_eid_persistence: Purposes 1 and 4). The gate lives in one place, UserInfo::for_auction, used by both auction request builders, so the Prebid Server and APS bodies inherit it.

Base

Targets main, not the identity stack. Main has the same leak (build_auction_request built ts-{ec_id}; /auction set user.id on ec_allowed() alone), and Fastly and Cloudflare production derive GDPR jurisdiction from geo, so it is live there.

Note for the identity stack: #1640 moves this logic into set_auction_ec_identity and adds bidder_ec_id. When main is next merged up the stack, keep ts-req-<random> for the request id and route user.id through UserInfo::for_auction (or apply allows_eid_persistence around bidder_ec_id).

Behavior

Consent Before After
GDPR, Purpose 1 only id = ts-<EC> (server-side auction, page-bids); user.id = EC (all paths) id = ts-req-<random>; no user.id; EC nowhere in the body
GDPR, Purposes 1 and 4 same as above user.id = EC; id = ts-req-<random>
GDPR applies, no TCF signal (including proxy consent mode with a TC cookie) user.id = EC if EC allowed no user.id (fails closed, as EIDs already do)
Outside GDPR with a TCF signal granting Purpose 1 but not Purpose 4 (e.g. a US state whose CMP uses TCF) user.id = EC no user.id (same rule as partner IDs)
GDPR does not apply, no TCF signal user.id = EC unchanged

The server-side request id is no longer stable per visitor; anything that correlated auctions by ts-<EC> loses that.

Where the EC can reach an outbound bid body

Path Status
Request id, server-side auction and page-bids (publisher.rs) Fixed: random
Request id, /auction (formats.rs) Already a random UUID
user.id, both builders Gated by UserInfo::for_auction
Prebid Server / APS profile bodies (auction/openrtb.rs), mediator, request signing Copy the gated id/user.id
user.ext.eids Already gated by gate_eids_by_consent (same rule)
Cookies and headers to providers Never carry the EC (consent-cookie allowlist only)
Testlight proxy (integrations/testlight.rs:111) Not gated, not changed here: it writes the ts-ec cookie into the upstream user.id without any consent check. Proposed as a follow-up.

Out of scope: #1685 (may widen the purpose rule; change both rules together via allows_eid_persistence) and #1704 (Prebid Server-side scrubbing).

Changes

File Change
crates/trusted-server-core/src/auction/types.rs Add UserInfo::for_auction, the single user.id gate; unit tests for its branches
crates/trusted-server-core/src/publisher.rs build_auction_request: random request id, gated user; update tests that expected ts-{ec_id}
crates/trusted-server-core/src/auction/formats.rs convert_tsjs_to_auction_request uses the gate; Purpose-1-only test
crates/trusted-server-core/src/auction/openrtb/tests.rs Prebid Server and APS body tests through the real builder and openrtb::build_request
crates/trusted-server-core/src/auction/endpoints.rs /auction handler tests capturing what providers receive
crates/trusted-server-core/src/auction/test_support.rs, crates/trusted-server-core/src/test_support.rs Test fixtures: server-side auction request builder, Purposes 1+4 consent
docs/guide/edge-cookies.md State that without Purpose 4 bid requests omit user.id and the request id is never EC-derived
CHANGELOG.md Security entry

Closes

Closes #1707

Spec

Not a feature

Test plan

  • cargo test -p trusted-server-core --lib (native host): 3395 passed, 0 failed. Hosted CI runs the full gate list on this PR; it was not run locally.
  • cargo clippy-fastly
  • cargo fmt --all -- --check
  • JS tests: not touched
  • JS format: not touched
  • Docs format: prettier (pinned 3.8.1) on CHANGELOG.md and docs/guide/edge-cookies.md
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via Viceroy (see below)
  • Other: tests written first and failed on main behavior; negative controls (below)

Tests fail first. Before the fix, 6 of the 7 new tests failed; for example, the Purpose-1-only Prebid Server body was {"id":"ts-<EC>", … "user":{"id":"<EC>"} …}. The body tests build the request with the real server-side builder, route it, build the actual Prebid Server and APS bodies, and assert the EC's hash appears nowhere in the whole serialized JSON.

Negative controls. Removing the allows_eid_persistence filter fails 5 tests (including both body tests and the /auction handler test); restoring ts-{ec} as the request id fails 5 tests.

Runtime (Fastly wasm under Viceroy 0.22.0, local). Client IP mapped to Germany (jurisdiction GDPR); Prebid Server and APS providers pointed at a local HTTPS capture server; /auction and /_ts/page-bids called with a fictional EC cookie and a synthetic TCF cookie. Same requests against main (db36dc0) and this branch:

Build Consent /auction PBS + APS /_ts/page-bids PBS + APS
main Purpose 1 only user.id = EC id = ts-<EC>, user.id = EC
this branch Purpose 1 only no user.id, EC absent id = ts-req-…, no user.id, EC absent
main Purposes 1 + 4 user.id = EC id = ts-<EC>, user.id = EC
this branch Purposes 1 + 4 user.id = EC id = ts-req-…, user.id = EC only

No captured request header carried the EC. Not runtime-tested: Cloudflare, Spin and Axum (Axum and Spin have no geo source today, so jurisdiction is Unknown and no EC is forwarded there), and any deployed environment.

Independent review. One local review pass against main and the issue: no blocking findings. Its optional findings (rustdoc link to a crate-private item, missing CHANGELOG/doc mention) are fixed in this PR; the Testlight gap is listed above as a follow-up.

Checklist

  • Feature PRs: not a feature
  • Changes follow AGENTS.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses log macros (not println!)
  • New code has tests
  • No secrets or credentials committed

The server-side auction and page-bids built the bid request id as
ts-<EC>, and every auction path set user.id to the EC whenever EC
creation was allowed, which under GDPR is TCF Purpose 1 alone. Prebid
Server bidders and APS therefore received the EC with storage consent
only.

Build the server-side request id as ts-req-<random> and decide user.id
in one place, UserInfo::for_auction, which requires the same rule that
gates partner EIDs (Purposes 1 and 4). Both auction request builders use
it, so the Prebid Server and APS profile bodies inherit the gate.
@prk-Jr prk-Jr self-assigned this Nov 30, 2026
@prk-Jr
prk-Jr marked this pull request as ready for review November 30, 2026 13:07

@dhruv8sh dhruv8sh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR stops bidders from receiving the EC when a reader grants TCF Purpose 1 but refuses Purpose 4. I found no blocking issues.

  • Request ID: the bid request id is now always ts-req-<random>. It is no longer ts-<EC>.
  • user.id: it now goes through one helper, UserInfo::for_auction. The helper sends the EC only when allows_eid_persistence allows it, the same rule that already gates partner EIDs. Both outbound builders use it: convert_tsjs_to_auction_request and publisher::build_auction_request.

I searched the other places that build UserInfo directly. They look like test fixtures, not production paths that skip the gate. I couldn't run anything, so I haven't checked the test or CI results.

Tests cover these cases:

  • the helper's consent rules, with and without Purpose 4, GDPR without a TCF signal, and outside GDPR;
  • an empty EC;
  • the /auction handler end to end;
  • the Prebid Server and APS bid bodies, with a check that the EC appears only in user.id.

The CHANGELOG notes that anything downstream that matched auctions by the old per-visitor request ID loses that link. That is intended.

@ChristianPavilonis ChristianPavilonis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Both auction builders now use the existing EID consent rule for user.id and generate request IDs independently of the EC. I verified that the Prebid Server and APS bid-body regressions passed in Fastly CI for this revision. No blocking findings.

Comment thread CHANGELOG.md

### Security

- Bidders no longer receive the EC when a reader grants TCF Purpose 1 but refuses Purpose 4 (#1707). The server-side auction and `/_ts/page-bids` built the bid request `id` as `ts-<EC>`, and every auction path set `user.id` to the EC whenever EC creation was allowed, so Prebid Server bidders and APS received it with storage consent alone. The request `id` is now always `ts-req-<random>`, and `user.id` carries the EC only under the rule that already gates partner EIDs: Purposes 1 and 4 when a TCF signal is present, and no `user.id` when GDPR applies without one (including proxy consent mode with a TC cookie). Anything downstream that correlated auctions by the old per-visitor `ts-<EC>` request ID loses that correlation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking: could we scope the EC guarantee here and in docs/guide/edge-cookies.md to the built-in auction paths? Also, only publisher navigation and /_ts/page-bids use ts-req-; /auction keeps its existing UUID.

Suggested change
- Bidders no longer receive the EC when a reader grants TCF Purpose 1 but refuses Purpose 4 (#1707). The server-side auction and `/_ts/page-bids` built the bid request `id` as `ts-<EC>`, and every auction path set `user.id` to the EC whenever EC creation was allowed, so Prebid Server bidders and APS received it with storage consent alone. The request `id` is now always `ts-req-<random>`, and `user.id` carries the EC only under the rule that already gates partner EIDs: Purposes 1 and 4 when a TCF signal is present, and no `user.id` when GDPR applies without one (including proxy consent mode with a TC cookie). Anything downstream that correlated auctions by the old per-visitor `ts-<EC>` request ID loses that correlation.
- When a reader grants TCF Purpose 1 but refuses Purpose 4, Trusted Server omits the EC from bid requests it builds for publisher navigation, `/_ts/page-bids`, and `/auction` (#1707). Publisher navigation and `/_ts/page-bids` now use `ts-req-<random>` instead of `ts-<EC>`, so downstream consumers can no longer correlate auctions using that per-visitor request ID. `/auction` keeps its random UUID. The EC in `user.id` follows the same consent rule as partner EIDs: when decoded TCF consent is available, it requires Purposes 1 and 4. When GDPR applies without decoded TCF consent, including proxy consent mode with a TC cookie, Trusted Server omits `user.id`.

@dhruv8sh dhruv8sh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

This PR stops the EC from leaking into bid request IDs: AuctionRequest.id is now always ts-req-<uuid>. It also moves the user.id decision into one helper, UserInfo::for_auction, which uses the same rule that already gates partner EIDs (allows_eid_persistence: TCF P1+P4, and fail closed under GDPR with no TCF). Both the server-side/page-bids builder (publisher::build_auction_request) and the /auction path (convert_tsjs_to_auction_request) now go through it. The tests are strong: they serialize the whole request or outbound body and assert that the EC hash appears nowhere, or exactly once. They do this through the real /auction handler and the real PBS and APS OpenRTB builders. I checked that nothing in production parsed or stripped the old ts-<EC> request-ID prefix. The ec_allowed / allows_eid_persistence doc links resolve.

Non-blocking

⛏ nitpick

  • purpose_one_and_four_consent silently returns P1-only consent if the base fixture ever loses its TCF — see inline at crates/trusted-server-core/src/test_support.rs:104

👍 praise

  • Single choke point for user.id, with a doc comment that ties it to the EID rule — see inline at crates/trusted-server-core/src/auction/types.rs:107

Cross-cutting / body-level findings

  • 📌 The Testlight integration still sets user.id from the ts-ec cookie without any consent check. crates/trusted-server-core/src/integrations/testlight.rs:111 (via handle at line 190) puts the EC into the outbound payload's user.id without consulting allows_eid_persistence. Testlight is a test/dev auction proxy, so it is probably out of scope here. But the CHANGELOG entry says "every auction path set user.id to the EC", which implies all of them are now gated. Consider a follow-up issue that either gates Testlight the same way or scopes the CHANGELOG wording to the server-side auction, /auction and /_ts/page-bids.

#[must_use]
pub fn purpose_one_and_four_consent() -> ConsentContext {
let mut consent = purpose_one_only_consent();
if let Some(tcf) = consent.tcf.as_mut() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⛏ nitpick — If purpose_one_only_consent() ever stops setting tcf, this fixture quietly returns P1-only consent. Every "with Purposes 1 and 4" test would then fail with a confusing user.id mismatch instead of a clear fixture error. Failing loudly makes the fixture's assumption explicit:

Suggested change
if let Some(tcf) = consent.tcf.as_mut() {
let tcf = consent
.tcf
.as_mut()
.expect("should have TCF consent in purpose_one_only_consent");
// Purpose 4 is index 3.
tcf.purpose_consents[3] = true;

pub eids: Option<Vec<crate::openrtb::Eid>>,
}

impl UserInfo {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍 praise — Funnelling both auction builders through UserInfo::for_auction and reusing allows_eid_persistence gives the EC-to-bidders decision one source of truth. The doc comment spells out why Purpose 1 alone isn't enough and asks future editors to keep the two rules together. The table test covers P1+P4, P1-only, GDPR-without-TCF and non-regulated consent, which pins exactly the boundaries that matter.

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.

Keep the EC out of bid request IDs and gate user.id on EID consent

3 participants