Skip to content

Add Edge Cookie (EC) sync support for trusted-server integration#98

Open
ChristianPavilonis wants to merge 4 commits intomainfrom
feature/ec-support
Open

Add Edge Cookie (EC) sync support for trusted-server integration#98
ChristianPavilonis wants to merge 4 commits intomainfrom
feature/ec-support

Conversation

@ChristianPavilonis
Copy link
Copy Markdown
Contributor

Summary

  • Add three new endpoints (/sync/start, /sync/done, /resolve) that enable mocktioneer to act as a full EC sync partner with trusted-server — supporting pixel sync redirect chains, callback handling, and S2S pull sync resolution
  • Add OpenRTB 2.6 user.eids support and embed EC identity metadata (EdgeCookieInfo) in creative HTML comments, enabling end-to-end demo of the trusted-server EC identity pipeline
  • Add examples/register_partner.sh for one-step partner registration with trusted-server

New Endpoints

Route Method Purpose
/sync/start?ts_domain=... GET Sets mtkid cookie, redirects browser to TS /sync
/sync/done?ts_synced=... GET Callback from TS — returns 1x1 pixel
/resolve?ec_hash=...&ip=... GET Pull sync — returns deterministic mtk-{sha256(ec_hash|ip)[0:12]}

Security

  • Constant-time auth: Token comparison uses subtle::ConstantTimeEq on SHA-256 digests (no length leak)
  • Open redirect protection: ts_domain validated as clean hostname (no /, @, :, ?, #) + optional allowlist via MOCKTIONEER_TS_DOMAINS env var
  • Input validation: ec_hash requires exactly 64 hex characters; log output sanitized against control chars
  • Deterministic IDs: mtkid derived from SHA-256("mtkid:" || host) — no randomness per CLAUDE.md

Testing

  • 97 unit tests + 1 ignored (env-var auth, passes separately with --ignored)
  • 12 APS integration tests, 7 endpoint integration tests
  • cargo fmt, cargo clippy clean

WASM Note

MOCKTIONEER_PULL_TOKEN and MOCKTIONEER_TS_DOMAINS use std::env::var which returns Err on Cloudflare Workers. Auth and domain allowlist are silently disabled on that platform. Documented in code comments.

Implement mocktioneer as a full EC sync partner with three new endpoints:
- GET /sync/start: pixel sync redirect chain (sets mtkid, redirects to TS /sync)
- GET /sync/done: callback endpoint completing the redirect chain
- GET /resolve: S2S pull sync resolution (deterministic UID from ec_hash+IP)

Also adds OpenRTB 2.6 user.eids support and EC identity metadata in creatives,
enabling end-to-end demo of the trusted-server EC identity pipeline.

Security hardening from review:
- Constant-time token comparison via subtle::ConstantTimeEq (SHA-256 digest)
- Hostname validation on ts_domain (rejects path/auth/port injection)
- Domain allowlist via MOCKTIONEER_TS_DOMAINS env var
- Hex-only ec_hash validation
- Log sanitization for user-supplied values
- Deterministic mtkid generation (SHA-256 of host, no randomness)
Prebid Server places eids under user.ext.eids (OpenRTB 2.5) rather than
the top-level user.eids (OpenRTB 2.6). extract_ec_info() now checks both
locations, with top-level taking priority when both are present.
@ChristianPavilonis ChristianPavilonis marked this pull request as ready for review March 31, 2026 12:24
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.

2 participants