Skip to content

Guard serving runtime environment names - #1637

Open
prk-Jr wants to merge 2 commits into
feat/1573-axum-production-servingfrom
feat/1580-runtime-env-guard
Open

prk-Jr wants to merge 2 commits into
feat/1573-axum-production-servingfrom
feat/1580-runtime-env-guard

Conversation

@prk-Jr

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

Copy link
Copy Markdown
Collaborator

Summary

  • Prevent serving code from reintroducing legacy or unreviewable process-environment reads. Clippy resolves aliases, function references and macro expansions; runtime_env! validates constant names during metadata-only checks.
  • Preserve the seven existing reads through four individually justified Fastly metadata exceptions. Build inputs, test poison values, operator tools, Worker bindings and EdgeZero-owned configuration remain outside this runtime gate.
  • Stack on Finish Axum production startup on the native baseline #1635 (feat/1573-axum-production-serving). Independent of Drain after-response tasks on SIGTERM #1575; no Axum startup, shutdown or after-response changes.

Changes

File Change
scripts/lint-runtime-env.sh, scripts/clippy-runtime-env/clippy.toml Compiler-backed guard across native Axum, Fastly WASI, Cloudflare WASM and Spin WASI, including shared serving packages and both Fastly production feature modes
scripts/test-runtime-env.sh 38 compiler fixtures covering forbidden names, aliases, scans, macros, dynamic names, equivalents, approved constants and exemptions
crates/trusted-server-core/src/runtime_env.rs, src/lib.rs Checked environment-read macro and individually justified platform allowlist
Fastly src/{app,middleware,platform}.rs, core src/integrations/datadome.rs Seven mechanical read replacements; existing result handling preserved
Core and JS build.rs Explicit exemption for build-time inputs
.github/workflows/format.yml, AGENTS.md Existing Rust lint job integration and documented CI gate
Design and implementation plan Approved scope, alternatives, verification and two independent review rounds

Closes

Closes #1580

Spec

Runtime environment guard design

Implementation plan

Test plan

  • scripts/test-runtime-env.sh: 38 fixtures pass; test-first controls showed the unchecked legacy read and unchecked macro were accepted before enforcement.
  • scripts/lint-runtime-env.sh: all four production targets pass, including separate default and reusable-sandbox Fastly checks with Rust/Clippy 1.98.1 and Node 24.20.0.
  • Feature-mode control: the earlier runner accepted a default-only Fastly legacy read; the corrected runner rejects it at that read site. Conditional fixtures cover both modes.
  • Actual guard rejects an injected TRUSTED_SERVER_CONFIG_POISON read on a disposable source copy with the expected policy lint at the read site.
  • cargo test --locked -p trusted-server-adapter-axum --test startup: 8 pass, including prepared-store loading and legacy poison rejection.
  • cargo test --locked -p trusted-server-core --lib protection_test_bypass: 9 pass.
  • cargo test --locked -p trusted-server-adapter-fastly --target wasm32-wasip1 version_header: 4 pass under Viceroy 0.21.0.
  • cargo clippy --locked -p trusted-server-core --lib -- -D warnings, cargo fmt --all -- --check, shellcheck for both new scripts, targeted Markdown formatting, and the workflow Node-pin guard.
  • Real branch-built Axum binary starts via the copied local task launcher and prepared local stores on a custom port: health 200, compiled JS 200, unknown bundle 404. An isolated compatibility config omits the unsupported Prebid mode input. Operator config and environment files remain untouched; owned server stopped.
  • Full CI: deliberately deferred to GitHub; the full gate list was not run locally.

Checklist

  • Spec linked above, with two independent review rounds
  • Changes follow AGENTS.md conventions
  • No secrets or operator configuration committed
  • New enforcement has positive and negative compiler fixtures
  • Production behavior preserved; no EdgeZero implementation changes
  • Final independent self-review at fa4a1a0285edd8a01ed3d2bf8fedc3d1057c8b88: no remaining blocking or optional findings; description reconciled

@prk-Jr prk-Jr self-assigned this Nov 19, 2026
@prk-Jr prk-Jr linked an issue Nov 19, 2026 that may be closed by this pull request
1 task
@prk-Jr
prk-Jr marked this pull request as ready for review November 19, 2026 13:21

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.

CI guard: runtime code reads only TRUSTED_SERVER__ environment names

1 participant