Skip to content

Apply consent rules to first-party click redirects - #1713

Open
prk-Jr wants to merge 15 commits into
prfection/1669-creative-endpoint-gating-planfrom
fix/1693-click-redirect-disclosure
Open

prk-Jr wants to merge 15 commits into
prfection/1669-creative-endpoint-gating-planfrom
fix/1693-click-redirect-disclosure

Conversation

@prk-Jr

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

Copy link
Copy Markdown
Collaborator

Summary

  • Apply current-request consent to EC insertion on first-party click redirects while preserving validated signed navigation when disclosure is denied.
  • Redact click EC values and omit target URLs and other request metadata from click logs.
  • Cover the click caller with an available EC for unknown jurisdiction, expired consent and GPC outside the US, with positive delivery controls.

An available cookie/header EC was previously inserted into click destinations regardless of consent. The click handler now uses the request's consent context and the shared allows_proxy_ec_disclosure predicate before inserting that EC. Signature and expiry validation still run first.

Base and scope

Targets prfection/1669-creative-endpoint-gating-plan (#1675), with reviewed base bbbd23407551f51a34dd090cf76c86619edfea7a. This PR is now part of the identity integration chain; earlier descriptions targeting main are historical.

The base already supplies the shared disclosure predicate, its direct table test, and the stricter creative content-proxy policy. This PR connects the click handler to current-request context on Fastly, Axum, Cloudflare and Spin. Review fixes add caller tests and correct documentation; they do not change the currently correct runtime gate.

Behavior and policy boundaries

  • Click EC insertion requires unexpired consent, no GPC in any jurisdiction, EC creation consent and EID persistence consent (TCF Purposes 1 and 4 where applicable).
  • Denial preserves the validated signed target and its existing query. A ts-ec already embedded by the creative is preserved too: this rule controls insertion of the request EC, not sanitization of arbitrary signed tracking parameters. This follows Apply the proxy disclosure rule to first-party click redirects #1693's unchanged-target requirement.
  • Click logs retain parameter presence and a redacted EC prefix. Target/tsurl, Referer and User-Agent are omitted deliberately; URL-bearing inputs can themselves contain identifiers.
  • The inherited content-proxy policy has a separate, stricter contract: canonical existing cookie identity, current consent and an explicit matching HTTPS recipient grant at every send. It strips reserved EC query values when disclosure is not authorized.
  • Rewrite switches enable routes; they do not grant consent.
  • Jurisdiction detection is unchanged. The existing country-only US follow-up is tracked in Apply US rules to a US request with no resolved state on every adapter #1705 and Apply strict US consent when the state is unresolved #1718; no duplicate issue is needed here.

The creative-processing guide, first-party proxy guide and API reference describe the click contract. The shared helper's documentation names both current callers and its conditions.

Closes

Closes #1693

Spec

Bug fix; no new feature contract or configuration key.

Verification

Review-fix commit: 91ff4240a145cff077f940a6f7f3185e71894d2b. The committed files match the verified working-tree content. Rust 1.98.1 and Node 24.20.0 were selected; runtime/build tools match this branch's .tool-versions and Cargo.lock (Fastly 16.0.0, Viceroy 0.22.0, Spin 4.1.0, Wrangler 4.83.0, worker-build 0.8.5, wasm-bindgen 0.2.126).

  • Full required local command list in AGENTS.md: adapter lint/test matrix, parity, JS build/tests and formatting, documentation/Markdown formatting, build-digest test/lint, deadline runtime fixtures, script checks, domain scan, environment guards and fresh production health/startup smokes on all four adapters.
  • Native core proxy suite: 185 passed. Click-related selection: 28 passed. Parity: 42 passed. The inherited shared-helper table and actual-send content-proxy policy tests pass.
  • Discriminating controls: weakening only the click caller rejected expiry/non-US GPC cases while the helper table stayed green; an unconditional caller rejected Unknown jurisdiction. Restoring the caller passed. Bypassing inherited content-proxy consent also made its actual-send test reject the request; restoring it passed.
  • Independent internal source review of the combined PR and review delta: no material findings.
  • Rust API docs build completed, with 31 warnings in existing documentation links. This is not a warning-free documentation claim.
  • Hosted CI: all 34 checks passed on 91ff4240a145cff077f940a6f7f3185e71894d2b.

The initial provider-helper attempt was denied localhost listening by the sandbox; the authorized rerun passed all 19 tests. Local provider acceptance here covers the required script helpers; the hosted container jobs remain part of current-revision CI verification. Existing intentionally ignored tests remain ignored.

No deployment or live vendor API qualification is claimed.

Checklist

  • Current-request consent reaches click handling on all four adapters.
  • Signed-target, HMAC and expiry behavior preserved.
  • Available-EC denial cases and positive delivery controls covered.
  • Documentation distinguishes click insertion and content-proxy disclosure.
  • Fictional test values only; operator configuration and environment files untouched.
  • Full required local gates and all 34 current-revision hosted checks passed.

@prk-Jr prk-Jr self-assigned this Nov 30, 2026
@prk-Jr
prk-Jr marked this pull request as ready for review December 1, 2026 11:26

@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.

Reviewed 57f2772ee against main (db36dc0ec).

Approving so I'm not blocking, on the understanding that you'll handle the comments before merging. The click gate itself looks right.

R1 · Nonblocking: docs/guide/creative-processing.md still describes the old click behavior. This one sits outside the diff, so it's here instead of inline. Lines 139-146 still say /first-party/click "appends the request's ts-ec value to the landing URL and logs the click with it" and that "both endpoints forward whatever EC ID the request carries". After this PR, click only appends ts-ec when current-request consent allows it and logs a redacted prefix, while /first-party/proxy still forwards unconditionally. Please reword that paragraph and keep "neither switch is a consent control". The dated design spec with the same wording can stay as it is.

Questions:

  • When consent is denied, a ts-ec the creative already signed into the target still goes through (click_consent_refusal_preserves_existing_signed_query locks that in). Stripping it wouldn't affect signature validation, because the target is rewritten after validation. Is keeping it intended?
  • The info log also drops tsurl, Referer and User-Agent. The issue only asked to redact the EC and drop the EC-bearing target. Was losing the click destination in logs deliberate?

Checks: cargo test -p trusted-server-core --lib -- click proxy_disclosure allows_eid (25 passed), native clippy on core, cargo fmt --check. I relied on CI for the adapter and wasm targets.

Comment thread crates/trusted-server-core/src/proxy.rs Resolved
PR #1713 moves from main onto PR #1662's branch, the top of the identity chain trunk. PR #1662's head brings the identity integration chain as of round 12 wave A, including the creative proxy disclosure policy and fallible Spin request setup.

crates/trusted-server-adapter-spin/src/app.rs: #1713 builds the request EC context for the click route and passes it to handle_first_party_click. The chain made the Spin services and request lookups fallible with `?` and an explicit Ok::<Response, EdgeError>. The resolution keeps the chain's fallible setup and adds #1713's build_ec_context call and argument, as the chain's proxy route does.

crates/trusted-server-core/src/proxy.rs: both sides changed imports. #1713 imports log_id with EcContext and adds GeoInfo and base64 test imports. The chain already imports EcContext and switched the test imports to the outbound client and crate::platform::GeoInfo. The resolution keeps the chain's imports, adds log_id, and keeps base64. The click handler keeps #1713's consent gate, which uses the same allows_proxy_ec_disclosure predicate the chain's ProxyDisclosureContext uses for creative fetches. #1713's click_geo test helper builds the chain's GeoInfo with GeoInfo::country_region.

docs/guide/first-party-proxy.md: #1713 describes consent-gated click disclosure and redacted click logs. The chain replaced the redirect propagation and logging sections with the creative endpoint grant policy. The resolution keeps the chain's sections, takes #1713's behavior list item, adds #1713's click forwarding conditions under the chain's "Click ID forwarding" heading, and drops "identity" from the chain's list of click behaviors that stay unchanged. The chain removed `forward_ec_id`, so the tip now points creative fetches at the endpoint grants instead.

crates/trusted-server-adapter-axum/src/app.rs (merged clean, failed to compile): #1713 calls build_ec_context, which the chain's Axum adapter no longer has. The resolution reads the request through state.identity.read_request and passes ec.context, as the chain's first-party proxy route does.

@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 gates ts-ec injection on /first-party/click behind the consent context of the current request, using the new allows_proxy_ec_disclosure helper. That helper requires consent that is not expired, no GPC, allows_ec_creation and allows_eid_persistence. The PR also threads an EcContext through all four adapters and stops the click log from recording the target URL, Referer, User-Agent and the full EC ID. The logic is correct and fails closed (a default EcContext resolves to Unknown jurisdiction, which blocks disclosure). Every adapter call site is updated consistently, and the tests use real TC-string and US-privacy cookies decoded through read_from_request_with_geo, so they exercise the full path. I found no blocking issues.

1 of the inline comments below carries a one-click GitHub suggestion. Use Commit suggestion to apply it as a commit on the PR branch. The other comments describe the change in prose because it touches code outside the diff.

Non-blocking

🤔 thinking

  • Content-proxy path still forwards ts-ec without a consent check — see inline at crates/trusted-server-core/src/proxy.rs:1651

🌱 seedling

  • No tests for Unknown jurisdiction, expired consent, or the helper itself — see inline at crates/trusted-server-core/src/proxy.rs:3232

⛏ nitpick

  • Helper doc comment says "creative proxy", but its only caller is the click redirect — see inline at crates/trusted-server-core/src/consent/mod.rs:502

👍 praise

  • Click log redaction — see inline at crates/trusted-server-core/src/proxy.rs:1667

Cross-cutting / body-level findings

  • 📝 Known gap with country-only US geo, documented in the PR — docs/guide/first-party-proxy.md openly says that country-only US geolocation (including Cloudflare's) resolves to NonRegulated, so a us_privacy=1YYY opt-out is not enforced on click redirects. GPC is still enforced because the helper checks !ctx.gpc regardless of jurisdiction. It is good that this is written down. Please file a follow-up issue for the strict US fallback so the gap doesn't stay only in the docs.

Comment thread crates/trusted-server-core/src/proxy.rs Resolved
Comment thread crates/trusted-server-core/src/proxy.rs Resolved
Comment thread crates/trusted-server-core/src/proxy.rs Resolved
PR #1662's new head brings wave B: #1506's merge of main ab5c24f (#1501, js_asset_proxy rewriter ordering) and its repin of EdgeZero to rc/identity 8a73c0978806, carried up through the chain. The merge is clean.
The click forwarding tip said country-only US geography selects NonRegulated and
that a strict US fallback was a separate fix. Jurisdiction detection belongs to
#1718, which makes a missing or unreadable US region strict, so the sentence
would go stale once both land. The tip now says US opt-outs follow the same
jurisdiction and consent rules as EC creation and links the Consent Model
section instead of describing detection.
@aram356
aram356 changed the base branch from main to feat/1598-ec-route-fastly December 1, 2026 23:14
aram356 added a commit that referenced this pull request Dec 1, 2026
One octopus merge of the round 12 tips into rc/identity c3e3366. It is a single octopus because the RC already holds every sibling's old head, so each tip's new head merges in alongside the others rather than as a chain of merges. The tree is the automatic merge of the RC and all tips, with no resolution: every tip pair, their union and the merge into the RC are clean.

Tips, in parent order after the RC:

- PR #1503 at 4225024
- PR #1653 at 4bd4903
- PR #1654 at 95cf3e8
- PR #1655 at 05c509d
- PR #1622 at afe5217
- PR #1660 at c1a05d7
- PR #1666 at 108b122
- PR #1659 at 5fb8190
- PR #1709 at 6d152f6
- PR #1710 at dcceeee
- PR #1713 at cae7801
- PR #1557 at 302e972

PR #1659 sits above PR #1718, so it carries PR #1714, PR #1717 and PR #1718.
@aram356

aram356 commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Round 12 identity realignment: rc/identity is now at db7dce634, and EdgeZero is pinned to its rc/identity at 8a73c097. This branch fast-forwarded from 57f2772ee to cae7801b1:

The base moved from main to feat/1598-ec-route-fastly. The click handler keeps the allows_proxy_ec_disclosure gate on the chain's request flow, and a doc commit points the click disclosure docs at the consent model instead of describing jurisdiction detection, which #1718 changes.

Each merge message says what it carries and how any conflict was resolved.

PR #1662's new head brings #1535's owner fix that keeps mirrored GPP consent through transient CMP not-ready states (#1678), #1535's move of the consent-update test host to publisher.example.com for the URL-host lint and #1540's allow-domain marks on the deployment guide's reference links. The merge is clean.
aram356 added a commit that referenced this pull request Dec 2, 2026
It brings #1535's owner fix that keeps mirrored GPP consent through transient CMP not-ready states (#1678), #1535's and #1540's URL-host lint fixes, and #1622's move of the new GPP bridge tests into its split test file, carried up to every tip: #1653, #1654, #1655, #1622, #1660, #1666, #1659, #1709, #1710, #1713 and #1557. #1503 is already contained. The octopus tree is the conflict-free union of the tips.
PR #1662's new head brings #1506's move of the five auction endpoint test requests from test-publisher.com to publisher.example.com, for the URL-host lint. The merge is clean.
aram356 added a commit that referenced this pull request Dec 2, 2026
It brings #1713's cascade merge of #1506's auction endpoint test host fix.
PR #1713 moves from PR #1662's branch onto PR #1675's branch, prfection/1669-creative-endpoint-gating-plan, which sits on PR #1662. PR #1675's head (e16189e) brings the creative and auction endpoint switches and PR #1662's latest head (14749b9).

crates/trusted-server-core/src/proxy.rs: both sides changed the test imports. #1675 widened the test_support import with assert_endpoint_turned_off and assert_turned_off_log, and #1713 added the base64 import for its signed click tests. The resolution keeps both. The handlers merged clean: handle_first_party_click takes #1713's EcContext and still checks #1675's click switch first, before it reads the signed target or the consent. The merge broke one call site: #1675's call_creative_endpoint test helper called handle_first_party_click without an EcContext. It now passes an empty one, as it already does for handle_first_party_proxy. The switch tests answer before the handler reads the context, so they still prove the click gate, and #1713's consent tests are unchanged.
…tches

PR #1675's new head (20bf514) joins its third review (7c08e50) with its move onto the identity chain. The third review adds a test that each creative endpoint works while only its own switch is on, rewords the cached-page notes to cover open tabs, documents that rewrite_clicks applies only where rewriting runs, and moves assert_turned_off_log below assert_endpoint_turned_off. The merge is clean.

crates/trusted-server-core/src/proxy.rs: the third review's creative_endpoints_work_when_only_their_own_switch_is_on reaches /first-party/click through call_creative_endpoint, which already passes an empty EcContext to handle_first_party_click. The third review adds no other caller, so none needs the new argument.
PR #1675's new head (54969a7) merges PR #1662's new head (20f849f), which merges PR #1661's head (a3c937f). It brings EdgeZero ef5cbf308, which includes EdgeZero #524 and names Fastly backends with the ez_b31v2_ prefix, and pin-project-lite 0.2.19 from PR #1506. It also brings PR #1626's mirror changes (mirror_provider_policy_denied, SharedIdWriteBackTime), the two smoke-test fixes in PR #1627 and PR #1537, and PR #1535's change that skips re-posting an unchanged Sourcepoint consent mirror. The merge is clean.
aram356 added a commit that referenced this pull request Dec 3, 2026
PR #1503 at 1d51b78: Add ts ec show and ts ec eids admin diagnostic commands
PR #1653 at f217902: Clarify and verify the Axum local config handoff
PR #1654 at e4e68bb: Verify pending record writes drain within shutdown grace
PR #1655 at 7d0cdb2: Configure EC lifetime and renew it on eligible visits (DEC-13)
PR #1659 at bd707f2: Verify geo consent paths on Axum and Fastly
PR #1660 at 87c52cd: Retry an after-response write that loses its CAS
PR #1666 at b1d7062: Verify identity gates and provider deadlines on Axum
PR #1710 at 3d33359: Apply pull-sync consent checks to identify
PR #1557 at 3982143: Carry Sourcepoint TCF consent to Trusted Server
PR #1667 at f9ac6bb: Present a client certificate on auction providers that set mtls
PR #1607 at b3a0b09: Send the resolved client IP to the publisher origin
PR #1709 at 635f06a: Keep the EC out of bid request IDs and gate user.id on EID consent
PR #1713 at e5f4d05: Apply consent rules to first-party click redirects
PR #1622 at dd2ee39: Report CMP consent to the EC route and merge its answer into Prebid
@aram356
aram356 changed the base branch from feat/1598-ec-route-fastly to prfection/1669-creative-endpoint-gating-plan December 3, 2026 11:35
@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Round 15 identity realignment: rc/identity is now at 391a08578, and EdgeZero is pinned to its rc/identity at ef5cbf308. This branch fast-forwarded from c7a94e2cf to e5f4d0590:

The base is now prfection/1669-creative-endpoint-gating-plan (#1675). The proxy.rs imports are the union of both sides, and #1675's call_creative_endpoint now passes &EcContext::default() to handle_first_party_click. The click consent gate still runs first, and #1675's switch tests fail without it.

Each merge message says what it carries and how any conflict was resolved.

Carries #1533's Axum startup-test port fix (779e446) and nothing
else. Owner commits pushed to other chain PRs since round 15 come in
with the next round.
@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Cascade of #1533's Axum startup-test port fix (779e44673): 13110b600 merges it into this PR. There were no conflicts and nothing else changed. The fix moves free_loopback_port in crates/trusted-server-adapter-axum/tests/routes.rs below the ephemeral port range, and #1533's note has the details. Owner commits pushed to other chain PRs since round 15 come in with the next round. rc/identity is now 62f8e41e2.

@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Merged #1627's runtime KV removal (7c2b84f45) into this branch as f6bc97d4f, on top of 13110b600.

At the maintainer's request, that commit removes the generic runtime KV store trusted_server_runtime_kv. Nothing reads or writes it, and the managed Fastly deploy made every service provision and pay for it. edgezero.toml and the Fastly Hooks::stores() now declare only trusted_server_kv, and RuntimeServices::kv_store() is unavailable on every adapter.

Only that commit was merged, not the base branch's new head. Conflicts were resolved in edgezero.toml, the Fastly Hooks::stores() in app.rs, fastly.toml, the Viceroy template, the integration tests' config.rs, trusted-server.example.toml, docs/guide/architecture.md and docs/guide/edgezero.md. Only trusted_server_kv stays declared, this branch's record-store comment and local seeds are kept, and the runtime-KV lines are dropped. The Axum README and docs/guide/axum-dev.md keep this branch's Axum wording. CHANGELOG.md keeps this branch's entry and drops the runtime-KV one.

Checks on this head: no reference to the removed store remains and cargo fmt --check passes; clippy-fastly, clippy-axum, clippy-cloudflare and clippy-spin-native pass. rc/identity (b9dc3153e) passed the full CI gate list with the removal.

PR #1675's new head brings #1487's change that strips `ts-eids` from publisher-origin requests unless the operator opts in and #1646's fix that preserves filter headers through identity finalization. The merge is clean.
aram356 added a commit that referenced this pull request Dec 3, 2026
PR #1503 at 6a8797e: Add ts ec show and ts ec eids admin diagnostic commands
PR #1557 at a435778: Carry Sourcepoint TCF consent to Trusted Server
PR #1607 at 07086f2: Send the resolved client IP to the publisher origin
PR #1627 at 5b7fc3d: Wire declared stores and document unsupported Axum KV
PR #1636 at d838931: Drain Axum after-response identity tasks on SIGTERM
PR #1653 at 5b86d9b: Clarify and verify the Axum local config handoff
PR #1654 at be495b3: Verify pending record writes drain within shutdown grace
PR #1655 at 888c5f1: Configure EC lifetime and renew it on eligible visits (DEC-13)
PR #1659 at 7b1d4a7: Verify geo consent paths on Axum and Fastly
PR #1660 at 64a1baa: Retry an after-response write that loses its CAS
PR #1667 at 1359722: Present a client certificate on auction providers that set mtls
PR #1709 at bc43a3e: Keep the EC out of bid request IDs and gate user.id on EID consent
PR #1710 at dc728a1: Apply pull-sync consent checks to identify
PR #1713 at ffa7597: Apply consent rules to first-party click redirects
PR #1722 at 070e2b0: Use applicable GPP sections from the CMP instead of header sections

PR #1666 at 4720b0b (Verify identity gates and provider deadlines on Axum) arrives through #1659, and PR #1622 at c878e6e (Report CMP consent to the EC route and merge its answer into Prebid) arrives through #1722. Every other chain PR arrives through the tips above. The tree is the conflict-free union of these tips and carries no resolution of its own.
@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Round 17 identity realignment: rc/identity is now at 0ed862633, and EdgeZero stays pinned to its rc/identity at ef5cbf308. This branch fast-forwarded from f6bc97d4f to ffa75975e:

Each merge message says what it carries and how any conflict was resolved.

@prk-Jr

prk-Jr commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the body-level review feedback in 91ff4240a.

  • The creative-processing guide now describes conditional click EC insertion and redacted logging, while preserving the distinction between rewrite switches and consent controls.
  • Preserving a ts-ec already inside the creative-signed target is intentional: Apply the proxy disclosure rule to first-party click redirects #1693 explicitly requires the validated target to remain unchanged when consent denies insertion of the request EC. Validation happens first, so stripping afterward is technically possible; keeping the query is a compatibility choice, not a signature requirement. The guide now states this boundary.
  • Dropping tsurl, target, Referer and User-Agent from the click info log is deliberate. URL-bearing fields can already contain identifiers, so the retained contract is parameter presence plus a redacted EC prefix.
  • The sibling content-proxy protection and direct helper table are now inherited from the stacked base. Its stricter canonical-cookie/recipient policy remains separate from clicks. The existing country-only US follow-up is Apply US rules to a US request with no resolved state on every adapter #1705 with PR Apply strict US consent when the state is unresolved #1718; I have not opened a duplicate issue.

All required local gates passed, including fresh production startup smokes on all four adapters; all 34 hosted checks passed on this commit. Rustdoc completed with 31 warnings in existing documentation links; no deployment or live vendor qualification is claimed.

@aram356

aram356 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Merged #1614's /_ts/ local answers (48930c270) into this branch as 387e0f5fc, on top of 91ff4240a.

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 #1675's new head (d3f76b07b), 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.

Apply the proxy disclosure rule to first-party click redirects

4 participants