Repository navigation
Conversation
dhruv8sh
left a comment
There was a problem hiding this comment.
PR Review
Summary
This adds a bounded, static-allowlist sanitizer (config_diagnostics::ValidationReport) for typed app-config validation failures. Approved path+code pairs keep fixed operator explanations through EdgeError::ConfigValidation; everything else is redacted, including every validator field name, both at runtime and in CLI validate/push/diff. The sanitizer is well bounded and thoroughly tested. However, the blanket field-name redaction removes useful diagnostics from the operator's own CLI.
😃 Praise
- 😃 A tight, well-bounded sanitizer (
crates/edgezero-core/src/config_diagnostics.rs:200). The walker spends its budget before allocating or sorting attacker-sized maps and sorts keys so output is deterministic. Matches must be exact path+code, with wildcards for list indices only. Tests cover every limit at N and N+1 and plant canaries in messages, params, map keys, and nested names. Apps that don't opt in keepConfigOutOfDate. - 😃 Shared adapter contract fixture.
contract_fixture::extraction_error()runs the real store read, validation, and error mapping through all four adapters' response conversion in one place.
Findings
Blocking
- 🔧 CLI validate/push/diff no longer says which field or rule failed (
crates/edgezero-cli/src/config.rs:265,:473,:650).- Symptom:
FixtureConfigwith[service] timeout_ms = 50now printstyped app-config failed validation: app config failed validation for field `<redacted>.<redacted>`. Before this PR it namedservice.timeout_msand the range rule. This affects every app that hasn't registered a diagnostic for every rule.typed_errors_on_validator_rule_failureonly checks for the word "validation", so CI doesn't catch it. - Why it can be narrower: the threat (a runtime-derived map key used as a field name) can be targeted precisely. Every public
ValidationErrorsbuilder (add,merge,merge_self,merge_all) takes&'static strand storesCow::Borrowed. Onlyerrors_mut().insert(Cow::Owned(..))yields a runtime key, and derived map validation uses numeric indices. - Fix: keep the
CowinActualSegmentand redact only owned keys. Then assert thatservice.timeout_msappears intyped_errors_on_validator_rule_failure;runtime_validation_redacts_untrusted_map_keysstill covers the hostile case.enum ActualSegment<'tree> { Field(&'tree Cow<'static, str>), Index(usize) } // render_path fallback: ActualSegment::Field(Cow::Borrowed(name)) if is_safe_ident(name) => name, ActualSegment::Field(_) => "<redacted>",
- Symptom:
Non-blocking
- 🤔 The public
field_pathis always the literal"<redacted>"(crates/edgezero-core/src/config_diagnostics.rs:228; emitted aterror.rs:114and:318), even for approved diagnostics, so it tells a client almost nothing. The fix above restores static names. Otherwise, omit the key when every segment is redacted. - 🤔 The operator message redacts a field and then names it (
crates/edgezero-core/src/config_diagnostics.rs:140). It reads…for field `<redacted>`; implementation [implementation_unavailable]: …. When diagnostics are present, skip the genericfor field …prefix. - 🤔 Existing
ConfigOutOfDatematches silently miss approved failures (crates/edgezero-core/src/error.rs:32). Downstreammatches!(e, EdgeError::ConfigOutOfDate { .. })checks returnfalseonce an app registers any diagnostic. Consider a publicis_config_out_of_date()covering both variants, and mention it in the migration guide. - ⛏
--no-default-featureshas no effect (.github/workflows/test.yml:115) becauseedgezero-corehas no default features. Also,runtime_approved_diagnostic_tracks_compiled_availabilityusescfg!(feature = "test-utils"). Feature unification means the refusal branch only runs in this separate step, so a comment on the test explaining that would help. - ⛏ Duplicate diagnostics (
crates/edgezero-core/src/config_diagnostics.rs:239). The same approved code on the same field is pushed twice, using 2 of the 8MAX_DIAGNOSTICSslots. Skip the push when the previous(field_path, code)matches. - 🌱
#[app_config(diagnostics = …)]on a nested-only child is silently ignored (crates/edgezero-macros/src/app_config.rs:664). A future lint could flag it.
📌 Out of Scope
- 📌 Rust 1.99 clippy failure: with no
rust-toolchain.toml, clippy 1.99 fails on existing code atcrates/edgezero-macros/src/app_config.rs:478(rest_pattern_accessible_field). Worth tracking before the next toolchain bump.
CI Status
Run locally on the pinned Rust 1.98.1:
- fmt: PASS
- clippy: PASS
- tests: PASS
- check
--features "fastly cloudflare spin": PASS - spin
wasm32-wasip2check: PASS
ChristianPavilonis
left a comment
There was a problem hiding this comment.
😃 Approved — no blocking correctness or security defects found.
The shared, bounded approval registry preserves fixed operator diagnostics without retaining validator messages or parameters. The extraction-backed adapter contracts provide strong coverage of the operator/public boundary.
Review observations
- The loss of unregistered field names in typed CLI validate/push/diff is real, but is an intentional, documented default-redaction trade-off rather than an accidental implementation error. I do not consider it blocking for this opt-in contract.
- I independently checked the earlier borrowed-key suggestion:
Cow::Borrowedproves lifetime, not schema provenance. A runtime-derived key held inOnceLock<String>can reachValidationErrors::addas borrowed. The current sanitizer correctly redacts it; the borrowed-key shortcut would weaken that protection. Preserving more CLI field locations would require a trusted schema-metadata approach. - A focused probe exercised real typed CLI entry points and the
#[action]extraction →RequestLogger→ Axum service →SimpleLoggerpath. Approved explanations reached operator output; validator message/value canaries did not. HTTP stayed coarse: 503,config_out_of_date, andRetry-After: 60.
Verification
Passed locally with Rust 1.98.1:
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-targets— 1,565 passed, 1 ignoredcargo check --workspace --all-targets --features "fastly cloudflare spin"cargo check -p edgezero-adapter-spin --target wasm32-wasip2 --features spin- Separate core compiled-implementation refusal and feature-enabled success controls
- Fastly and Cloudflare WASM contract compilation
- Spin WASM contract execution — 13 passed
- Cloudflare browser/WASM contract execution — 14 passed
- Workflow actionlint with explicit installed tool paths
- Focused standalone CLI, borrowed-runtime-key, and native Axum logging/public-response probes
Local Fastly runtime execution was not repeated because installed Viceroy is 0.17.0 rather than the pinned 0.21.0. I inspected the actual Fastly CI log: Viceroy 0.21.0 ran the new contract successfully, with 8 contract tests and 97 runtime unit tests passing. Docs/demo startup checks were not repeated locally; GitHub checks are green.
Reviewed all 17 changed files at head eba3ce157259a49b15d0b7c5d737871cbc084284 against base/merge-base e11ea3082f66ec864aabdd6007b15c4926c73b82. No production source changes were made during review.
Summary
Integration note: a current
git merge-treecomparison with #509, #512, #514 and #515 reports conflicts in Axum response conversion, Cloudflare/Spin contracts, and core error/extractor code. These siblings need reconciliation when integrated.Changes
edgezero-core/config_diagnosticsedgezero-core/app_configandedgezero-macros#[app_config(diagnostics = REGISTRY)]root registrationedgezero-core/extractor,error, andmiddlewareConfigValidationerror and operator accessor; keep HTTP 503,config_out_of_date, andRetry-After: 60edgezero-cli/config.github/workflows/test.ymltest-utilsUnknown validator field names are now redacted, including names that could be attacker-controlled map keys. Applications opting in should account for
ConfigValidationor usevalidation_diagnostics()/operator_message(); existingConfigOutOfDateconstructors remain supported. Extraction adds no store read, complete-policy reparse, or second validation pass.Closes
Closes #457
Test plan
Historical author-reported local verification below (original head unrecorded unless an explicit SHA is given). These results, counts, timings and negative controls were not rerun in this audit, and their underlying local logs were unavailable; checked boxes retain the original report. At the current head
eba3ce15, all 28 reported hosted checks are passing.Local checks used Rust 1.98.1 and Node.js 24.20.0.
cargo test --workspace --all-targets— 1,565 passedcargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --all -- --checkcargo check --workspace --all-targets --features "fastly cloudflare spin"fastly clicombination and Spin's relocated contract testtest-utils, and the same policy's feature-enabled success controlactionlint .github/workflows/test.ymlexamples/app-demoworkspace tests — left to CInpm run lint,npm run format, andnpm run buildedgezero serve --adapter axumChecklist
edgezero_core