Skip to content

feat(axum): add safe diagnostics and trusted proxy metadata - #409

Open
ChristianPavilonis wants to merge 39 commits into
issue-393-buffered-body-limit-specfrom
issue-397-diagnostics-proxy-trust-spec
Open

ChristianPavilonis wants to merge 39 commits into
issue-393-buffered-body-limit-specfrom
issue-397-diagnostics-proxy-trust-spec

Conversation

@ChristianPavilonis

@ChristianPavilonis ChristianPavilonis commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Current review readiness — 2026-11-10

Ready for review at the publication head below. The required workspace and test aggregate have now passed in run42916832735; all 29 latest checks pass. Reviewers: aram356, prk-Jr, dhruv8sh.

Review transitions are independent of TS work and the combined integration audit; #462 remains draft. This current status supersedes historical draft-only prerequisites below without claiming unexecuted deployment/manual acceptance complete. All three reviewers are requested. Stack465 is the current grouping; #453 is excluded.

Current review-stack checkpoint

Publication head: 5bbff2bf6d6d853b470f76e7293b7ecfa55476f5. This cleanup preserves the existing feature unit and PR identity. The additional change is the completed generated-native build correction: image-only code now follows the scaffold's existing Fastly-example selection, with no request-policy change. Its focused generator/native proof is retained; fresh per-branch hosted checks are not assumed green.

Review order: #275 → #406 → #407 → #409 → #414 → #422 → #439 → #454. Draft integration checkpoint: #462. New SDK/group/codec/phase development and unrelated TS work are not prerequisites or additions to this PR. Earlier notes below retain their original tested revisions and limits; they are not a whole-tree pass for this new head.

Earlier implementation and proof notes

RC refresh checkpoint, 2026-11-10

Current head: 3b52b804e5570564cc95cdaaf4b9efc6307875ae.

Checked forwarding trusts the actual socket peer, validates the selected family and preserves original normalized-head accounting before stripping assertions and entering application callbacks. Diagnostics retain the existing terminal owner/time and redact raw values. Independent source review found no unresolved correctness defect.

The CLI-only diagnostics gate is fixed, with 57 CLI-only tests passing. Native ingress trust is now under edgezero_adapter_axum::trusted_proxy, leaving the current outbound legacy-API guard unchanged. Parent namespace proof passes 370 Axum unit, 28 contract and 32 production-hosting tests plus axum-only strict Clippy. Nested demo resolution matches existing exact workspace getrandom0.4.2/ipnet2.12.0 requirements; no manifest pin was relaxed.

This layer does not strip a future protected-CloudFront credential or prove a Geo reader identity.

Draft pending fresh hosted checks and the combined RC audit. Two unchanged native default-parallel deadline misses remain recorded and unclassified; serial passes and untouched-foundation parallel passes do not clear them. No timing bound was relaxed. No deployment, main merge, security-alert dismissal or review-thread resolution occurred. Historical design/review context follows.


Summary

  • Add opt-in, socket-peer-gated proxy trust and checked native ingress metadata. No proxies are trusted by default; managed admission strips both forwarding families.
  • Add safe correlated native records, request IDs, coherent work snapshots and an optional observer at the existing response terminal owner. Preserve application logging, completions, observers and custom rendering.
  • Use fixed native framework routing and JSON-deserialization error text, publish operator guidance, and add real proxy/TLS/socket regression coverage.

Changes

Crate / file Change
edgezero-adapter-axum Bounded literal policy/parser, owned metadata, strict settings, identity/counters/records, hosting integration and selected-status capture
edgezero-core Checked host witness, original normalized-head summary, timestamp-aware joined completion and bounded failure provenance; no report-shape or portable Tokio/Send change
Native fixtures Source-bound .2/.3 relays, verified test TLS with wrong-name control, 32 production-hosting cases, callback/panic/privacy/counter checks and defensive fallback tests
Docs Operator/migration guide, immutable reviewed specification and implementation/acceptance record

The approved JSON extension retains HTTP 400 and unmanaged serde detail. Custom renderers still own their response, but native framework JSON-deserialization errors now reach them as invalid JSON payload. Application-authored EdgeErrors are not globally sanitized. Managed raw-forwarding-header removal is documented as a compatibility change; the low-level converter remains a trust-policy bypass.

Dependency changes are four direct Axum edges to existing locked packages. Rustls and Tokio Rustls are dev-only. The published TLS private key is an explicitly public test asset, never a deployment credential.

Closes

Closes #397.

Stack and acceptance

Part of #391. This PR remains draft until the required integration and acceptance gates are satisfied.

Stacked above #407 using gh stack, at base 3308041b910b648af746c15e809ee86b96adc2e9. The user authorized implementation on this open stack. That exception does not satisfy accepted #275/#393 integration or authorize bypassing #394/#395 upload experiments. Accepted-stack, final-image and deployed-ingress acceptance remain deferred.

Test plan

Local checks passed for implementation commit 66a05e2:

  • cargo test --workspace --all-targets — 1,938 passed, one existing ignored generated-workspace compile smoke
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check and git diff --check
  • cargo check --workspace --all-targets --features "fastly cloudflare spin"
  • All three adapter WASM checks: Fastly wasm32-wasip1, Cloudflare wasm32-unknown-unknown, Spin wasm32-wasip2
  • cargo test -p edgezero-adapter-axum --all-targets --all-features — 255 library, 13 contract and 32 hosting cases
  • cargo test -p edgezero-core — 731 library tests plus integrations/doctests; 13 existing ignored doc examples
  • Locked docs install, lint, format and build; compiled guide API/options/snapshot smoke
  • Excluded examples/app-demo workspace
  • Final image and deployed proxy/provider acceptance

docs/superpowers/plans/2026-10-06-axum-diagnostics-trusted-proxy.md records commands, timings, historical failures, source fingerprints, all 22 specification rows and proof boundaries. Final runtime-input manifest SHA256: ac40934b17bb6c521951f15090e2accf3059abcb4d386c6da74a69d95de8c9d7.

Local wire tests directly prove owned proxy peers, consumer agreement, verified TLS, selected 200 plus failure after an observed head/prefix, hook/cardinality preservation and graceful/grace-forced work release. Missing-peer, exhaustive parser/identity bounds, precise injected timing and defensive fallback branches remain service/unit evidence. Environment-derived secret/config error privacy is tested; declared-store/backend and actual outbound-origin experiments are not claimed. Explicit diagnostic stop fixtures do not prove the convenience second-signal-plus-native-snapshot combination. The existing supported convenience second-signal test is retained.

Independent source reviews found and resolved lost Abort failure classification and formatting drift. A maintenance-only duplicated IPv6 bracket split remains unchanged; node and authority port grammars differ. Docs installation reports seven existing audit vulnerabilities, two moderate and five high; no docs package changes were made.

Checklist

  • Follows CLAUDE.md; shared Cargo/global formatting centrally scheduled
  • No portable Tokio dependencies or Send migration
  • Brace-style route parameters and core HTTP types
  • No exporters, public diagnostics endpoints, tracing propagation or new terminal owner
  • Application hook/logger/renderer ownership preserved
  • Test keys are explicitly public fixtures; no deployment secrets committed
  • Distinguish local proof from downstream acceptance; keep the PR draft until its merge gates are satisfied

TS cutover follow-up, November 11

Native hosting invokes application head preparation after structural validation and before stripping forwarding fields. Protected Geo paths also capture facts before credential sanitation; invalid heads still skip application preparation.

Current head: 3708ffa418778b8ec3499daad132b1a3f9c7962f.

Local combined-RC qualification at 36f8e9c9c2c93661aaa73f2ca956cec3bc9e4c92: workspace tests 2,947 passed / 6 ignored; all-feature Axum 568 passed, including 36 production-hosting, 6 AWS startup and 4 celld startup cases; core doctests 19 passed / 13 ignored; strict workspace Clippy, formatting, feature compilation and Spin WASM check passed under Rust 1.98.1. Narrow TS consumer proof under Node 24.20.0: all four real proxy tests and typed prepared config/secrets/router startup passed. This is not final TS-stack/image/deployment qualification. Fresh hosted checks are still required.

Owned follow-up review checkpoint

  • Branch advanced through an ordinary merge; every previous public head remains an ancestor.
  • Current head: b8c65667e643f77dfa1cd61b79cee5bd7a95f552. Source tree a461a3dfd5ffa17698d452c034c935f59f365bea is byte-identical to previous head 31f46bde222ce3e942c1c801966ecc053a0305c9.
  • Related owned draft: #499. It is intentionally a placeholder until the author cleans feat: implement portable outbound HTTP and request lifecycle contracts #275 and the owned baseline/follow-up are reconciled.
  • Review base and ready/draft state are unchanged. The feature-only review diff is byte-identical to the pre-update diff.
  • Existing qualification remains tied to its recorded inputs. New hosted outcomes are reported separately; this history update does not qualify new source-version-bound binaries or move a release tag.

@ChristianPavilonis
ChristianPavilonis force-pushed the issue-397-diagnostics-proxy-trust-spec branch from 66a05e2 to 9fa1666 Compare November 10, 2026 19:54
Bring in PR #275's batch cutoff test fix, which advances the test clock
when the request arms its own deadline instead of after dispatch.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed c317517c, a merge of #407's new head that brings #275's 0e2a58ae, which fixes an intermittent failure of the batch cutoff test by advancing its clock when the request arms its deadline timer. It had no conflicts.

Keep failed trusted chains from substituting the socket peer for the client and use safe managed extractor errors without changing their status. Preserve typed stream failures, clock and cancellation semantics, and verify the native host and proxy fixtures.
@ChristianPavilonis

Copy link
Copy Markdown
Collaborator Author

Review follow-up: d37a57b8. The fixes were tested against the reviewed #407 base 9750b0e3.

  • The parallel port-race report is covered by the lower-stack reservation and respawn changes plus 7d085b1f and 9c4a2f70 in this PR. The 33-case hosting suite passed without serializing it. The separate connection.rs deadline flake is outside feat(axum): add safe diagnostics and trusted proxy metadata #409 and was left alone.
  • Added bare-development checks for invalid and non-Unicode native settings, plus wire coverage for both explicit builder paths. Core tests now assert both pre-dispatch fallback categories. The existing hosting test checks the original normalized-head byte formula. IPv6 parsing is covered in units; a separate IPv6 wire fixture is deferred.
  • A regressed egress instant no longer yields a native duration. Cancellation while validating a zero-length response stream records cancellation with no selected status. The response attempt still owns completion. When both native sinks are off, the guard releases accounting without allocating a request record.
  • The guide now explains why pre-service rejections are outside request telemetry. The changelog names the raw-header migration. The low-level converter remains a documented proxy-trust bypass.
  • The fixture key is public and test-only. Kept the existing TLS provider and verification; there is no scanner blocker in the reviewed checks. Provider changes, scanner exceptions, and certificate rotation tooling are deferred. The fixture README already records the expiry and renewal requirement.

Local Linux verification passed: 2,904 workspace tests, 33 hosting tests, 675 harness tests, strict Clippy, formatting, workspace feature compilation, Spin WASM, the Axum demo build, and docs format, lint, and build. macOS and deployed ingress were not run.

Stack dependency: #407 has since advanced to a3ad0428. A merge preview found conflicts in the native runner, options, service, and two hosting test files. This push carries only the reviewed #409 batch. It does not restack #409 or qualify that integration. The stack needs to be reconciled and retested before merge.

Keep the updated Axum startup and shutdown owner, explicit registries, and buffered JSON handling alongside proxy trust, request records, and diagnostics guard ownership. Preserve the production-hosting regressions from both parents.

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

PR Review

Summary

Found while reviewing the rc/identity integration branch (#495) and traced to this PR. Each finding was re-checked at this head (3f6d0da6); line numbers refer to it.

One non-blocking portability finding.

Findings

Non-blocking

  • 🤔 ForwardedHost is checked only on managed Axum. See extractor.rs:247.

CI Status

  • GitHub checks at 3f6d0da6: 29 of 29 pass.

impl FromRequest for ForwardedHost {
#[inline]
async fn from_request(ctx: &RequestContext) -> Result<Self, EdgeError> {
if let Some(checked) = ctx.extensions().get::<CheckedEffectiveHost>() {

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.

🤔 ForwardedHost is checked only on managed Axum; elsewhere it still returns the raw client X-Forwarded-Host

Only the Axum adapter inserts CheckedEffectiveHost. On Fastly, Cloudflare and Spin this falls through to the legacy branch (:250-257) and returns whatever X-Forwarded-Host the client sent. A portable app that uses ForwardedHost for redirects, cache keys or tenant routing gets a trust-checked value on Axum and a client-controlled one on the other three. Document the split on the extractor and in each adapter guide, or have the other adapters insert CheckedEffectiveHost from their own trusted host source.

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.

Addressed in 381eb66 with docs. The extractor doc comment now says only the managed Axum host checks the value, through CheckedEffectiveHost. On Fastly, Cloudflare, Spin and the low-level Axum converter it reads X-Forwarded-Host, then Host, which the client controls, so it must not drive redirects, cache keys or tenant routing unless a proxy you control sets or strips the header. The Fastly, Cloudflare and Spin guides have the same note. docs/guide/handlers.md (around line 205) still recommends ForwardedHost behind a proxy without this caveat; I left that page alone.

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

PR Review (follow-up)

Summary

Re-reviewed head 3f6d0da6 against stack base a3ad0428. The fix commit d37a57b8 addresses every item from my previous review, and I checked each one in the code rather than relying on the replies. One trust-boundary problem remains in the same area as the original trust-walk finding. Identity no longer collapses to the proxy, but a visitor who controls the leftmost part of the chain can still make EdgeZero discard the trusted proxy's host and scheme. One earlier doc question is also only half closed. I'm requesting changes for those two items.

😃 Praise

  • Failing closed on a malformed or unresolved trusted chain (effective_client() == None, Unavailable provenance, direct_peer() kept separately) is the right shape. The CHANGELOG entry makes the behavior change visible to upgraders.
  • The PendingValidation drop guard and the lazy record construction in RequestGuard::emit are small, focused fixes for the cancellation and allocation concerns.
  • The macOS proxy fixtures now skip with an actionable ifconfig lo0 alias message instead of failing with a misleading response head, and relay errors are no longer swallowed.

Prior findings status (my review at 31f46bde)

  • ✅ Trust walk collapses the client to the proxy's address (trusted_proxy.rs:413-438): Malformed and UnresolvedChain now clear effective_client and set client_source = Unavailable. Covered by direct_fallback / assert_client_unavailable and the service matrix at service.rs:3223-3240. A follow-on consequence for host/scheme is raised below as a new finding.
  • ✅ Duplicate Host becomes the checked direct host (trusted_proxy.rs:361-369): only a singleton Host (or a URI authority) yields a direct authority; duplicate_host_is_not_a_checked_direct_authority covers it.
  • ✅ Post-commit body-source failure category dropped (diagnostics.rs:563-565): NativeRequestRecord::source_failure is populated from the report and printed as source_failure=. The precommit zero-length path still retains the category through attempt.record_source_error (response.rs:672-675), and the wire test asserts the category.
  • ✅ Managed path/query/form/Validated* errors echo input (context.rs:808-814, 997-1001; extractor.rs): gated on FrameworkErrorDetail::CategoryOnly, which only the managed Axum service passes (service.rs:270-274). The dispatch tests cover both default and custom renderers in both modes.
  • 🔧 Unmanaged JSON redaction contradicts the guide: partially fixed. axum-diagnostics.md now says the low-level converter also uses fixed JSON text, and low_level_converter_keeps_native_fixed_json_parse_text pins it. docs/guide/adapters/axum.md:202-205 still says "Legacy/unmanaged JSON errors ... retain their existing behavior". See the inline comment.
  • ✅ Proxy/TLS hosting tests fail on macOS (production_hosting.rs:620-643, native_proxy.rs): the tests probe their source addresses and skip only on macOS AddrNotAvailable, panicking anywhere else. Relay errors now propagate through the worker JoinHandle<io::Result<()>>. I reran the axum suite locally on macOS without aliases; see CI Status.
  • ✅ (non-blocking) Guide omits the received-head preparer: the flowchart now has step P, and the text says the preparer sees unchecked headers (axum-diagnostics.md:89-104).

Findings

Blocking

  • 🔧 A visitor can still make EdgeZero discard the trusted proxy's host and scheme (trusted_proxy.rs:413, :708). See the inline comment.
  • 🔧 adapters/axum.md still contradicts the low-level converter's JSON redaction (docs/guide/adapters/axum.md:202-205). This is the remainder of the earlier ❓, and the fix is a one-paragraph doc change. See the inline comment.

Non-blocking

  • ⛏ Stale "falls back to the direct peer" sentence (axum-diagnostics.md:222-223). See the inline comment.
  • 🤔 Malformed forwarding is logged at WARN and the visitor can trigger it. Combined with the finding above, any client can produce one WARN record per request by sending a junk X-Forwarded-For. That is acceptable if WARN means "look at your proxy config", but consider INFO when the malformed slot lies beyond the trusted suffix, once the parser can tell the difference.
  • 📝 aram356's later 🤔 on ForwardedHost portability (extractor.rs:247) still applies. I'm not repeating it here.

CI Status

  • Hosted checks at 3f6d0da6: 29/29 pass (Run Tests, Run Format, CodeQL, Deploy actions).
  • Local, Rust 1.98.1 on macOS: cargo fmt --all -- --check PASS; cargo clippy -p edgezero-adapter-axum -p edgezero-core --all-targets --all-features -- -D warnings PASS; cargo test -p edgezero-core PASS (1,224 passed); cargo test -p edgezero-adapter-axum --all-targets --all-features PASS (435 lib, 28 contract, 40 hosting).
  • On macOS without loopback aliases, the four proxy/TLS hosting cases now print their skip notice instead of failing. They were not exercised here; Linux CI runs them.
  • Not rerun locally: the full workspace, feature check and WASM checks (hosted CI covers them).

),
None => return metadata,
};
let Ok(parsed) = parse_result else {

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.

🔧 A visitor can still make EdgeZero discard the trusted proxy's host and scheme

The identity collapse is fixed, but the whole-family check still covers the part of the chain the visitor wrote. Take the guide's own Cloudflare → LB topology. The visitor sends X-Forwarded-For: junk. Cloudflare and the LB append, and EdgeZero receives this from the trusted LB:

X-Forwarded-For: junk, 203.0.113.7, 198.51.100.10
X-Forwarded-Host: app.example.com
X-Forwarded-Proto: https

parse_node("junk") fails at line 708, the whole family becomes Malformed, and we return here with effective_scheme() == Http and effective_host() set to the direct Host. The LB-verified X-Forwarded-Proto: https and X-Forwarded-Host are thrown away. A 65th slot, an empty member, a 16 KiB prefix, or (for appending Forwarded proxies) an earlier element with proto=ftp does the same. whole_family_validation_includes_unselected_prefix_and_by_nodes and xff_empty_members_invalidate_even_good_host_and_proto currently pin this behavior.

Why it matters: the visitor chooses whether the trusted proxy's assertions apply. An app that builds absolute URLs from the checked scheme, or redirects when effective_scheme() != Https, will send that visitor an http:// link or a redirect back to the same HTTPS URL. The guide places a shared cache (Cloudflare) in front, and X-Forwarded-For is not part of the cache key. One request can therefore cache a redirect loop or http:// links for everyone (cache-poisoning DoS). It is also inconsistent: an unknown or obfuscated hop (UnresolvedChain) keeps the final-proxy host/scheme, but a junk hop further left drops them.

Fix (either one):

  • Preferred: validate only what the right-to-left walk consumes. Split the list into raw slots under the existing byte/slot bounds, then parse slots from the right and stop at the first untrusted or unknown node. A malformed slot to the left of that boundary is never interpreted. Host/proto (X-Forwarded-Host/-Proto singletons, or the final Forwarded element) are validated on their own.
  • Minimal: when the only defect is in the client-address chain, treat it like UnresolvedChain. The client is unavailable, the final-proxy host/scheme are kept, and Malformed is reserved for defects in the fields the final proxy owns.

Either way, please update the two tests above, the spec's "Malformed whole-set fallback" row, and the guide sentence "a present-empty value or empty member invalidates the complete selected family, including otherwise-valid host/proto". Then add a case asserting that a junk prefix behind a trusted suffix keeps https and the forwarded host.

Comment thread docs/guide/axum-diagnostics.md Outdated
Comment on lines +222 to +223
load balancer is trusted, it stops at the Cloudflare address. If every represented address is
trusted, it falls back to the direct peer as unresolved.

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 sentence describes the old behavior

After d37a57b8, a chain where every address is trusted gives UnresolvedChain with effective_client() == None and client_source() == Unavailable (trusted_proxy.rs:419-438). It no longer falls back to the direct peer. Read literally, this line tells operators that the LB address becomes the client, which is exactly what the fix removed.

Suggested change
load balancer is trusted, it stops at the Cloudflare address. If every represented address is
trusted, it falls back to the direct peer as unresolved.
load balancer is trusted, it stops at the Cloudflare address. If every represented address is
trusted, the chain is unresolved and the effective client is unavailable; `direct_peer()` still
reports the load balancer.

Comment thread docs/guide/adapters/axum.md Outdated
Comment on lines +202 to +205
Native-managed JSON deserialization failures return HTTP 400 with the fixed text
`invalid JSON payload`. Custom renderers receive that same fixed error, not serde detail.
Legacy/unmanaged JSON errors and application-authored `EdgeError` messages retain their
existing behavior. See [privacy limits](/guide/axum-diagnostics#timing-failures-and-privacy-limits).

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.

🔧 Still contradicts the low-level converter behavior (prior ❓ on unmanaged JSON detail, only partly resolved)

axum-diagnostics.md was corrected to say the low-level into_core_request converter attaches the native buffering policy and therefore also returns invalid JSON payload. low_level_converter_keeps_native_fixed_json_parse_text pins that. This paragraph still says unmanaged JSON errors keep their existing behavior, and that converter is the unmanaged path. Please align it:

Suggested change
Native-managed JSON deserialization failures return HTTP 400 with the fixed text
`invalid JSON payload`. Custom renderers receive that same fixed error, not serde detail.
Legacy/unmanaged JSON errors and application-authored `EdgeError` messages retain their
existing behavior. See [privacy limits](/guide/axum-diagnostics#timing-failures-and-privacy-limits).
Axum JSON deserialization failures on bodies carrying the native buffering policy return HTTP 400
with the fixed text `invalid JSON payload`. This includes the managed host and the low-level
`into_core_request` converter. Custom renderers receive that same fixed error, not serde detail.
Bodies without that policy, and application-authored `EdgeError` messages, retain their
existing behavior. See [privacy limits](/guide/axum-diagnostics#timing-failures-and-privacy-limits).

let direct_authority = if let Some(authority) = parts.uri.authority() {
parse_authority(authority.as_str().as_bytes()).ok()
} else {
let mut hosts = parts.headers.get_all(HOST).iter();

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.

😃 Nice, tight fix. The singleton-Host check now matches inbound_origin, URI authority still wins, and the test also covers a forwarded host being accepted while the direct authority is unavailable.


// Only this preparation step can suspend before selecting a response. If it is
// dropped, settle the begun attempt without claiming a status or starting a fallback.
struct PendingValidation<'attempt> {

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.

😃 Good call to settle the begun attempt as RequestCancelled when this future is dropped, instead of letting the Initial-state drop report ConversionError. cancelled_zero_length_validation_records_no_selected_status proves it end to end: there is no invented status, one record, and the source drops.

Fastly, Cloudflare, Spin and the low-level Axum converter supply no checked host, so the extractor returns the client's raw X-Forwarded-Host there.
Bring in PR #407's head, which now carries PR #460's rejection of
unusable surrogate cache tags and PR #275's review fixes: outbound
contract violations return 500, deadline-bounded Axum handoff, Spin
timer re-arm, validation messages without rejected values, the migration
docs and main's lockfile versions.

crates/edgezero-core/src/extractor.rs: PR #275 replaced the six
Validated* extractors' validator Display message with
validation_failure, which names the first violating field and its rule
but not the rejected value. This PR routed the same six call sites
through RequestContext::validation_error, so managed Axum hosting can
answer with category-only text. The resolution keeps this PR's
ctx.validation_error calls and makes validation_failure crate-visible.

crates/edgezero-core/src/context.rs (not conflicted): the Default branch
of RequestContext::validation_error now returns validation_failure
instead of the validator's Display, so the default path keeps PR #275's
rule and the category-only path is unchanged.

crates/edgezero-core/src/app.rs (not conflicted): this PR's
managed_extractor_errors_discard_input_before_rendering test expected
the Default-mode 422 message to echo the rejected sentinel. It now
expects the field-and-rule message, "value: failed `length` validation".

Cargo.lock: the lockfile merged as text but failed --locked, because
PR #275 restored main's tokio-rustls 0.26.5 and this PR pins
=0.26.4. Re-resolved offline from PR #407's lockfile. It adds this PR's Axum
dependency edges, sets tokio-rustls to 0.26.4 and lets cargo pick
windows-sys 0.61.2 on seven Windows-only edges. Every other entry
matches PR #407's lockfile.
Bring in PR #275's Fastly contract test fix, which expects the terminal
error body in the production key order (serde_json without
preserve_order sorts keys alphabetically). The merge is clean.
aram356 added a commit that referenced this pull request Dec 1, 2026
Bring in PR #439's native Geo sanitization fixes (a supplied provider
behind an untrusted forwarding policy) and the review fixes below it,
from PR #422 down to PR #275, including RunMode hosting,
native_request_setting, the development runner's refusal of the
bindings locator, the ForwardedHost note in the Fastly guide and
DEFAULT_SHUTDOWN_GRACE.

crates/edgezero-adapter-axum/src/run_options.rs: the defaults keep this
PR's optional manifest Geo (geo: None) and the base's
DEFAULT_SHUTDOWN_GRACE. fixed_setting checks this PR's geo_setting
first, then the base's native_limit_setting and native_request_setting.

crates/edgezero-adapter-axum/src/dev_server.rs: the imports keep this
PR's geo_setting and the base's native_request_setting. The base made
shutdown_grace private and no longer uses it here, so its import is
dropped. capture_dev_environment keeps PR #414's refusal of the
bindings locator and the base's native_request_setting lookup, and
adds this PR's geo_setting as the last fallback.

crates/edgezero-adapter-axum/tests/fixtures/production_host.rs:
run_geo_fixture keeps this PR's geo-manifest branch (options from the
environment and the baked manifest). In the explicit branch it adds PR
#439's untrusted X-Forwarded policy for geo-supplied-untrusted.

docs/guide/adapters/fastly.md: the resolution keeps PR #409's
ForwardedHost paragraph at the end of the preceding section and this
PR's new "Geographic context" section after it.
Bring in PR #275's Viceroy repair, which fails an if-generation-match
insert when the key has no live entry, so a stale generation cannot
recreate a deleted key. The merge is clean.
@aram356

aram356 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Round 12 identity realignment: rc/identity (#495) is now at 38cb74fe. This branch fast-forwarded from 381eb660 to 6fd1f2ca:

extractor.rs keeps this PR's ctx.validation_error call sites, and the Default branch uses #275's validation_failure.

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

@aram356 aram356 mentioned this pull request Dec 2, 2026
14 of 15 tasks
Bring in PR #275's lockfile update, which moves the yanked
pin-project-lite, chacha20 and yoke-derive versions to their
replacements. The merge is clean.
@aram356

aram356 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Round 15 identity realignment: rc/identity is now at ef5cbf308. This branch fast-forwarded from 6fd1f2cac to 7674c8d6a:

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

On managed Axum it returns the trust-checked host, not raw X-Forwarded-Host; elsewhere the raw header is client-controlled.
The fixed text follows the native buffering policy, which into_core_request attaches.
Name the ForwardedHost change on managed Axum and the fixed extractor and JSON error text.
A malformed or oversized visitor-written prefix left of the first untrusted hop no longer discards the host, scheme and client that trusted proxies appended, or raises the request record to WARN.
@aram356

aram356 commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator

Review follow-up: fixes committed to this branch

A full review of this PR turned up the problems below; each would otherwise have needed a follow-up ticket, so it is fixed on this branch instead. Every item names its commit.

  • ForwardedHost advice in the handlers guide was wrong on every adapter. It said the extractor reads X-Forwarded-Host first and should be used behind a proxy. On managed Axum the raw header is stripped and the extractor returns the trust-checked host (the direct Host when no trust is configured); elsewhere the header is client-controlled. 41e22a4 replaces the two comment lines with per-adapter behaviour and a warning against using the value for redirects, cache keys or tenant routing unless a proxy you control sets it, and links the diagnostics migration section. Docs only.
  • CHANGELOG did not mark the proxy-trust changes as breaking. The entry described three breaking changes as prose and never named ForwardedHost. f2ab54e splits it into three Breaking bullets: forwarding headers removed under every policy; ForwardedHost returning the checked or direct host, never raw X-Forwarded-Host; fixed extractor and JSON error text, including from the low-level converter.
  • A visitor-written prefix invalidated what trusted proxies appended (thread). Behind an appending trusted proxy, a visitor could prefix junk (X-Forwarded-For: junk, an empty member, 64 commas, a 16 KiB value, or a Forwarded element with proto=ftp or an unbalanced quote) and turn the whole family Malformed: the proxy-verified https scheme and host were dropped, the client became unavailable, and the request record went to WARN on demand. f45fbc1 makes the trust walk drive parsing: members are read right to left (field lines in reverse, quoted commas ignored, escaped quotes honoured) and parsing stops after the first untrusted or unknown node, so nothing left of the boundary is parsed. The 64-slot and 16,384-byte bounds apply to what the walk reads plus X-Forwarded-Host/X-Forwarded-Proto. A defect in a member the walk does read was written by a trusted proxy and still yields Malformed. New test a_prefix_beyond_the_boundary_never_invalidates_trusted_assertions covers junk, empty, 64-comma, oversized, proto=ftp and unbalanced-quote prefixes for both families, same line and separate lines; the whole-family, empty-member, slot-bound and byte-budget tests now put the defect behind a trusted hop; the hosting case bad-address through the appending proxy now expects accepted. Guide and spec rows updated.
  • Adapter guide said unmanaged JSON errors keep serde detail (thread). The low-level into_core_request converter attaches the native buffering policy and returns invalid JSON payload (pinned by low_level_converter_keeps_native_fixed_json_parse_text). db3914a applies the suggested wording. Docs only.
  • axum-diagnostics.md said an all-trusted chain falls back to the direct peer (thread). That chain is UnresolvedChain with no effective client. 164bc8e applies the suggested sentence. Docs only.

Fixes made on the PRs below this one in the stack were merged into this branch with merge commits.

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.

Axum: add safe production diagnostics and trusted-proxy handling

4 participants