Skip to content

Restrict creative proxy identity disclosure - #1615

Open
prk-Jr wants to merge 4 commits into
fix/1142-health-startup-contractfrom
docs/1233-proxy-disclosure-policy
Open

prk-Jr wants to merge 4 commits into
fix/1142-health-startup-contractfrom
docs/1233-proxy-disclosure-policy

Conversation

@prk-Jr

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

Copy link
Copy Markdown
Collaborator

Summary

  • Stop attaching reader EC identity to ordinary creative resources: disclosure is default-denied and requires an explicit HTTPS origin/path recipient plus a canonical cookie and current consent.
  • Evaluate every redirect independently and couple event delivery to upstream cache bypass, terminal private/no-store responses, restricted headers, and rejection of raw redirect escapes.
  • Share the policy with ts config proxy explain <URL> --json; preserve specialized integration/publisher asset fetching and verify actual CLI-to-Axum resource transport.

Changes

File Change
.github/workflows/test.yml Run the bounded Fastly proxy network fixture and runner self-checks.
crates/trusted-server-adapter-axum/src/app.rs Prepare current policy and pass the normal EC context to the creative handler.
crates/trusted-server-adapter-axum/src/middleware.rs Preserve terminal privacy when creative-route failures become HTTP responses.
crates/trusted-server-adapter-cloudflare/src/app.rs Prepare current policy and pass the normal EC context to the creative handler.
crates/trusted-server-adapter-cloudflare/src/middleware.rs Preserve terminal privacy when creative-route failures become HTTP responses.
crates/trusted-server-adapter-fastly/src/app.rs Prepare current policy and pass the normal EC context to the creative handler. Add actual withdrawal/finalization regression coverage.
crates/trusted-server-adapter-fastly/src/main.rs Register the test-only network fixture.
crates/trusted-server-adapter-fastly/src/middleware.rs Preserve terminal privacy when creative-route failures become HTTP responses.
crates/trusted-server-adapter-fastly/src/proxy_policy_runtime.rs Observe actual Fastly transport URLs, redirect stripping and exhaustion under Viceroy.
crates/trusted-server-adapter-fastly/tests/proxy-policy-origin.mjs Run an owned local origin with exact test discovery, bounded execution and cleanup.
crates/trusted-server-adapter-fastly/tests/proxy-policy-origin.test.mjs Reject missing selection, origin failure and timeouts; verify cleanup.
crates/trusted-server-adapter-spin/src/app.rs Prepare current policy and pass the normal EC context to the creative handler.
crates/trusted-server-adapter-spin/src/middleware.rs Preserve terminal privacy when creative-route failures become HTTP responses.
crates/trusted-server-cli/src/commands/config/mod.rs Register read-only proxy policy diagnostics.
crates/trusted-server-cli/src/commands/config/proxy.rs Implement shared-evaluator explain output with redaction and documented exits.
crates/trusted-server-cli/src/run.rs Wire the config proxy subcommand.
crates/trusted-server-cli/tests/config_env_overlay.rs Cover typed recipient validation and effective overlays during config publication.
crates/trusted-server-cli/tests/config_proxy.rs Exercise the actual explain command, overlays, invalid inputs and redacted output.
crates/trusted-server-cli/tests/proxy_trusted_server.rs Compare real CLI-mediated and direct Axum resource fetches for two readers.
crates/trusted-server-core/src/config.rs Reject invalid recipient configuration during typed deployment validation.
crates/trusted-server-core/src/consent/mod.rs Compose the current consent gate without generating identity or adding store work.
crates/trusted-server-core/src/integrations/google_tag_manager.rs Make shared-helper query identity explicitly disabled; preserve integration-owned behavior.
crates/trusted-server-core/src/integrations/gpt.rs Make shared-helper query identity explicitly disabled; preserve integration-owned behavior.
crates/trusted-server-core/src/integrations/js_asset_proxy.rs Make shared-helper query identity explicitly disabled; preserve integration-owned behavior.
crates/trusted-server-core/src/integrations/testlight.rs Make shared-helper query identity explicitly disabled; preserve integration-owned behavior.
crates/trusted-server-core/src/lib.rs Expose policy types and keep query mutation private.
crates/trusted-server-core/src/proxy.rs Apply authorization, narrow headers and event cache bypass before every creative send; reject terminal redirect escapes.
crates/trusted-server-core/src/proxy_policy.rs Validate and compile explicit recipients; model request consent and chain privacy.
crates/trusted-server-core/src/proxy_query.rs Remove reserved EC keys without rewriting unrelated query bytes; inspect raw redirect paths.
crates/trusted-server-core/src/response_privacy.rs Reassert terminal no-store and remove validators after operator response headers.
crates/trusted-server-core/src/settings.rs Add default-empty recipients, eager preparation and serialization/legacy-reader tests.
crates/trusted-server-integration-tests/README.md Document the evidence supplied by native policy route tests.
crates/trusted-server-integration-tests/tests/parity.rs Verify all three native routers, positive recipients, failures, redirects and rule removal.
docs/guide/configuration.md Document recipient validation, defaults, activation and rollback.
docs/guide/first-party-proxy.md Explain the revised disclosure, redirect, header and cache contracts.
docs/superpowers/plans/2026-11-16-1233-proxy-disclosure-policy.md Record implementation tasks, acceptance traceability and local verification.
docs/superpowers/specs/2026-11-16-1233-proxy-disclosure-policy-design.md Record the reviewed design, alternatives and production qualification requirements.
scripts/README.md Document the proxy network runner and its limits.
trusted-server.example.toml Show commented explicit recipients while retaining default denial.

Closes

Closes #1233

Spec

Proxy disclosure and cache policy, including two independent spec review rounds.

Implementation plan and A1–A22 traceability.

Test plan

The implementation checks below were recorded locally, except where explicitly marked as GitHub Actions or deployed staging evidence. Hosted CI status is separate and is not asserted here.

  • cargo test-fastly && cargo test-axum; also cargo test-fastly-reuse, cargo test-cloudflare, and cargo test-spin
  • cargo clippy-fastly && cargo clippy-axum; also Cloudflare native/WASM, Spin native/WASM, CLI and codegen lint aliases
  • cargo fmt --all -- --check
  • JS build, tests (3,299 passed / 80 files) and format
  • Docs format and production documentation build; Markdown checks outside docs
  • Native core library (3,408 passed; 2 existing ignored), native adapter parity (34 passed), build-digest tests (10 passed) and corresponding lints
  • Complete CLI tests including Chrome fixtures and real CLI→Axum→origin resource requests
  • Actual Viceroy network fixtures: five deadline cases and three creative proxy cases; four proxy-runner self-checks
  • Actual Fastly KV withdrawal/finalization regression; Cloudflare and Spin auction deadline runtime fixtures
  • Clock, Node pin, release producer, documentation proposal and added-line URL-host checks
  • Seven disposable-copy regression controls rejected unconditional identity, initial-hop-only query editing, absent positive wiring, missing bypass, lost chain privacy, and late validator/public-cache restoration
  • Fastly release artifact built through GitHub Actions; deployment receipts tie the tested staging artifact to ef13773ac35c52624bff60f733639bf7c7e91e28.
  • Manual testing via fastly compute serve
  • Deployed Fastly staging: actual static cache reuse and positive HTTPS event delivery/non-reuse, measured with a controlled HTTPS origin and synthetic reader identities.
  • Deployed Worker runtime qualification; the Fastly staging results do not cover Cloudflare or Spin deployments.

Configuration hardening and compatibility

Invalid recipient origins, paths, IDs, duplicate selectors and non-roundtripping paths return configuration errors during typed validation/runtime preparation; every adapter prepares settings before routing. No panic-based recipient compilation is used. Regression coverage includes proxy_identity_policy_rejects_invalid_runtime_configuration, identity_policy_rejects_invalid_origins, identity_policy_rejects_invalid_paths_and_rule_ids, identity_policy_rejects_duplicate_ids_and_normalized_selectors, and proxy_policy_rejects_selectors_changed_by_url_serialization.

Deploy the new binary before publishing a nonempty proxy.identity_endpoints configuration: older strict readers reject the new field. Empty defaults remain omitted. Existing signatures are still validated before query transformation, and removing a rule revokes future disclosure without re-signing URLs. Creative requests deliberately use a fixed user agent and restricted forwarded headers; unfollowed redirects carrying Location return 502. Integration-owned identity payloads and click behavior remain outside this policy.

Deployed Fastly qualification and remaining limits

Controlled HTTPS-origin checks passed against the deployed Fastly artifact from ef13773ac35c52624bff60f733639bf7c7e91e28:

  • Two readers fetched the same static resource with exactly one origin fetch. Direct HTTPS calibration requests separately confirmed that the temporary tunnel was not supplying the cache hit. Static requests disclosed no EC identity.
  • Repeated authorized events reached the origin independently and carried exactly one canonical identity for the correct synthetic reader. GPC and missing-cookie requests reached the origin without identity.
  • Event responses were Cache-Control: no-store, private, with validators and edge-cache directives removed, despite deliberately cacheable origin responses.
  • Redirects independently evaluated the destination, disclosed identity only to the approved event path, retained terminal privacy after an event-to-static redirect, and returned a private 502 without Location when the redirect limit was exhausted.
  • The receiver observed no forwarded browser Cookie or Authorization headers.
  • Headless Chrome checks covered page rendering, scripts, repeat visits, ads and client-side navigation.

The temporary recipient and fetch permission were removed by restoring and republishing the exact original staging configuration. Live checks confirmed the removed destination was denied without another origin request, while the homepage and existing allowed bundle still worked. Owned test processes and temporary credentials were removed.

These checks qualify the signed proxy policy on Fastly staging. They do not establish normal-page creative-proxy activation or a production recipient inventory: creative rewriting remained disabled, and no permanent identity-recipient rules were added. Cloudflare and Spin deployed qualification and manual fastly compute serve testing remain unperformed. Hosted CI must be assessed separately before requesting review or merging.

Checklist

  • Feature spec linked above and ends with two agent review rounds
  • Changes follow AGENTS.md conventions
  • No new unwrap() in production code
  • Uses log macros rather than println!
  • New code has regression tests
  • No secrets or credentials committed

Require explicit HTTPS origin and path grants plus current consent before disclosing canonical EC identity. Reevaluate every redirect and coordinate event cache bypass with terminal response privacy.

Add shared CLI diagnostics, adapter and real-network coverage, operator migration guidance, and the reviewed design and implementation plan.
@prk-Jr prk-Jr self-assigned this Nov 16, 2026
@prk-Jr
prk-Jr marked this pull request as ready for review November 17, 2026 11:27
Brings the identity integration chain, now including the health and startup
contract (#1617) on the EdgeZero cutover (#1506), into the creative proxy
disclosure policy, and keeps the policy on every adapter's proxy path.

Core proxy: proxy_request keeps the cutover's EdgeZero outbound client and
redirect follower. The creative identity policy now runs at the cutover's two
check points. The first target passes check_proxy_target, then CreativeHops
rejects userinfo, rewrites the reserved ts-ec query to the authorized identity
or to none, and picks the hop's cache policy. Each followed redirect goes
through redirect_policy, which, on the creative route, takes EdgeZero's
prepared request, applies the same per-hop decision with the raw Location path
check, and follows the rewritten request. Identity endpoints bypass upstream
caches. The chain state is shared with the policy, because EdgeZero keeps the
policy for the whole chain, and the final response becomes private once an
identity endpoint was visited. A final 3xx with a Location on the creative
route is an error, and creative responses strip the first-party passthrough
headers. The creative route sends the fixed creative header profile through a
header-profile choice in proxy_outbound_request. append_ec_id is gone, and
ProxyRequestConfig carries query_identity and disclosure in place of
forward_ec_id. Target logging drops the query, as the PR does.

Adapters: every adapter prepares the proxy policy when it builds state,
alongside the cutover's identity-provider rejection, and passes the request's
EcContext into handle_first_party_proxy. The finalize middleware keeps the
cutover's handler-error rendering and Fastly's RequestGeo, and marks 4xx and
5xx creative proxy responses terminal-private. Fastly's test-only service
injection in build_per_request_services is not needed on the cutover, so it is
not carried.

Core settings, config and consent: both sides' fields, checks, warnings and
test imports are kept. Testlight keeps the base's response cap and uses
without_ec_id.

Tests: the PR's core proxy policy tests, its parity module and its Fastly
named-route test run on ScriptedHttpClient in place of the removed platform
HTTP stubs, and read each hop's URI and cache policy from the recorded
requests. The parity origin answers by path through a request observer. The
Fastly named-route test routes with the cutover's outbound client and a held
US geo and runs the real entry-point finalize_response. The Fastly network
fixture uses EdgeZero's Fastly client. The cutover's first-party proxy readback
test now expects the creative header profile. The CLI proxy test keeps the
cutover's in-process Axum fixture. The CLI proxy explain tests create the
`[proxy]` table, which the cutover dropped from the integration fixture, so the
appended endpoint tables still parse.

Docs: the first-party proxy redirect list combines EdgeZero's redirect rules
with the per-hop identity policy and the creative terminal-redirect rejection,
and the proxy settings table keeps both sides' rows.
Takes #1617's new head 50bb96a, which brings #1506's repin of EdgeZero to
rc/identity at 9d02d7b3. The merge is clean, and this PR's tree changes only
by that repin.
@aram356
aram356 changed the base branch from main to fix/1142-health-startup-contract November 19, 2026 05:59
@aram356

aram356 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration chain (#1608), this PR now stacks on #1617, and its base is fix/1142-health-startup-contract. 06ce7c71c merges #1617's earlier head 5c6fb5df9, which carries the EdgeZero cutover (#1506) and the health contract. b1ab62e1b then merges #1617's new head 50bb96ad9, which adds #1506's repin of EdgeZero to rc/identity at 9d02d7b3. That merge is clean and changes this PR's tree by exactly the repin.

The cutover replaced the proxy's own redirect loop with EdgeZero's outbound client and redirect follower, so the disclosure policy now runs at the follower's two check points:

  • First hop. After check_proxy_target, a request-local CreativeHops rejects userinfo, rewrites the reserved ts-ec query to the authorized identity or to none, and picks the hop's cache policy. Identity endpoints bypass upstream caches.
  • Each followed redirect. redirect_policy takes EdgeZero's prepared request, applies the same per-hop decision with the raw Location path check, and follows the rewritten request. EdgeZero keeps one policy for the whole chain, so the chain state is shared with it through Rc<RefCell<ProxyChainState>>, and the final response becomes private once an identity endpoint was visited.
  • Final response. A final 3xx with a Location on the creative route is an error, and creative responses strip the first-party passthrough headers.
  • Headers and config. The creative route sends a fixed header profile, chosen through a new OutboundHeaderProfile in proxy_outbound_request. append_ec_id is gone, and ProxyRequestConfig carries query_identity and disclosure in place of forward_ec_id. Target logging drops the query.

What the follower changes. EdgeZero replays the same creative headers on each hop instead of this PR rebuilding them, and the values are the same. EdgeZero's cross-origin header stripping, its userinfo 502 and its 60 s chain deadline apply. Creative 4xx and 5xx privacy also covers handler errors rendered inside the middleware.

  • Adapters. Every adapter prepares the proxy policy when it builds state, next to the cutover's identity-provider rejection, and passes the request's EcContext into handle_first_party_proxy. The finalize middleware keeps the cutover's handler-error rendering and Fastly's RequestGeo, and marks 4xx and 5xx creative proxy responses terminal-private. Fastly's test-only service injection in build_per_request_services is not needed on the cutover, so it is not carried.
  • Settings, config, consent and Testlight. Both sides' fields, checks, warnings and test imports are kept. Testlight keeps the base's response cap and uses without_ec_id.
  • Tests. The 6 core policy tests, the 5 parity tests and the Fastly named-route test run on ScriptedHttpClient and read each hop's URI and cache policy from the recorded requests. The parity origin answers by path through a request observer. The Fastly named-route test routes with the cutover's outbound client and a held US geo, runs the real finalize_response, and asserts no further requests. The terminal-redirect test also checks that the echoed ts-ec is stripped on every hop. The cutover's first_party_proxy_request_readback now expects the creative header profile, with no user-agent passthrough, referrer or x-forwarded-for. The CLI config_proxy tests create the [proxy] table, which the cutover dropped from the integration fixture. No test is dropped.
  • Docs. The first-party proxy redirect list combines EdgeZero's redirect rules with the per-hop identity policy and the creative terminal-redirect rejection, and the proxy settings table keeps both sides' rows.

Checked locally at 06ce7c71c: cargo fmt, all eight clippy aliases and the core build-digest clippy, scripts/lint-wasm-clock.sh, test-fastly (4,101), test-fastly-reuse (249), test-axum (65), test-cloudflare (67), test-spin (90), parity (40), build-digest (10), host CLI tests (980), docs and Markdown format, and the URL-host lint against #1617, all passing. This PR's own CI step also passes: proxy-policy-origin.test.mjs 4 of 4, and proxy-policy-origin.mjs under Viceroy 0.21.0 3 of 3 network cases.

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.

Stop forwarding ts-ec to static creative assets through /first-party/proxy

2 participants