Repository navigation
fix(command): validate listener config before committing it to main-process state (#1301) - #1302
Merged
Merged
Conversation
…ess state
An HTTPS listener whose configuration the worker cannot build (an unusable TLS
version/cipher set, or an unparseable answer template) was recorded in the main
process's ConfigState before the worker rejected it, reserving the address. A
corrected reload was then refused with StateError::Exists and never reached the
workers, so the listener stayed down until an explicit RemoveListener or a
restart.
The main process now validates every Add{Http,Https,Tcp,Udp}Listener the way the
worker builds it, reusing the worker's own construction check
(HttpsListener/HttpListener::validate_config, factored out of try_new via a
shared build_answers helper so the two cannot drift), before ConfigState is
mutated and fanned out. An invalid listener therefore never reserves its address
and a corrected reload applies cleanly. The guard is wired into all three master
apply paths (worker_request, load_static_config, load_state); invalid listeners
in the static config or a loaded state file are skipped without reserving their
address (fail-open: one bad listener does not stop the others).
StateError::Exists now points at the remedy (remove it first, or apply the
corresponding update, instead of re-adding).
Tests: master-level regression tests in bin/src/command/requests.rs (proven red
by neutering the guard, then green) plus an #[ignore]d e2e smoke test that drives
a real master over its command socket and confirms a corrected `listener https
add` succeeds after an invalid one at the same address.
Closes #1301
Signed-off-by: Florentin Dubois <[email protected]>
…hange Defense-in-depth on top of the validate-before-commit guard (sozu#1301). Even after validation, a request the main process commits to its ConfigState and fans out can still be rejected worker-side. When EVERY worker it was scattered to rejects it (a unanimous, definitive failure: no timeout, none accepted), WorkerTask::on_finish now reverts the main process's own ConfigState with the inverse request, so its authoritative state (the one replayed into restarted and upgraded workers) never permanently holds an add the whole fleet refused. Because no worker applied the change, reverting the main process alone reconverges the fleet; there is nothing to compensate worker-side. A mixed result (some workers accepted) is deliberately left as-is to avoid diverging the main process from the workers that did accept. compute_rollback covers the non-upsert Add verbs whose inverse is unambiguous without capturing the prior value: every listener type (inverse RemoveListener) and HTTP/HTTPS frontends (inverse is the same payload under the Remove variant). Upsert verbs (AddCluster, AddBackend) and certificates would need the prior value to revert correctly and are deliberately uncovered (best-effort, as today). Tested: rollback_inverse_targets_the_same_listener_and_skips_uncovered_verbs. Refs #1301 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
commented
Jul 25, 2026
FlorentinDUBOIS
left a comment
Collaborator
Author
There was a problem hiding this comment.
Automated cross-review (review / review-code / guidelines / simplify / security-review + Codex, adversarially verified). Self-review on my own PR, so posted as COMMENT (GitHub blocks author approve/request-changes). Findings inline; batched into one review.
…InvalidInput Addresses the cross-review findings on #1302. - HIGH: handle_finishing_task (server.rs) passed a hard-coded timed_out=false into every GatheringTask::on_finish, discarding the real flag the two call sites pass (has_finished -> false, timeout expiry -> true). So timed_out was always false: the Part 2 !timed_out rollback guard was inert, and the audit FanoutStatus::Timeout/result branches were unreachable (a timed-out command was reported to the operator as "Successfully applied request to all workers"). Forward the real flag. New regression test handle_finishing_task_forwards_timed_out_flag (seen red without the fix). - LOW: worker_request tagged both a rejected validate_listener_request and a rejected state.dispatch as AuditErrorCode::DispatchError. Thread the failure class through apply_result so operator-invalid listener config tags InvalidInput (same class as the set_logging_level filter check) and only a genuine state conflict tags DispatchError. - NIT: soften the StateError::Exists message. It is shared by the four frontend kinds, which are add/remove only (no Update*Frontend request), so it no longer promises an update remedy some kinds lack. Refs #1301 Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1301. An HTTPS listener whose configuration the worker cannot build (an unusable TLS version/cipher set, or an unparseable answer template) was recorded in the main process's
ConfigStatebefore the worker rejected it, reserving the address. A corrected reload was then refused withStateError::Existsand never reached the workers, so the listener stayed down until an explicitRemoveListeneror a process restart — an operational trap where the natural fix-and-reload loop silently does nothing.Approach
Two commits, following the control-plane / data-plane static-stability principle (the control plane must not record what the data plane rejected):
Part 1 — validate before commit (the fix). The main process now validates every
Add{Http,Https,Tcp,Udp}Listenerthe way the worker builds it, reusing the worker's own construction check (HttpsListener/HttpListener::validate_config, factored out oftry_newvia a sharedbuild_answershelper so master and worker cannot drift — same binary, same crypto provider), beforeConfigStateis mutated and fanned out. An invalid listener therefore never reserves its address and a corrected reload applies cleanly. Wired into all three master apply paths (worker_request,load_static_config,load_state); invalid listeners in the static config or a loaded state file are skipped without reserving their address (fail-open: one bad listener does not stop the others). This extends an idiom already inworker_request(theSetMetricDetailmaster-side pre-validation).StateError::Existsnow also points at the remedy.Part 2 — rollback safety-net (defense-in-depth). Even after validation, a committed change can be rejected worker-side. When every worker rejects it (unanimous, no timeout), the main process reverts its own
ConfigStatewith the inverse request, so its authoritative state (replayed into restarted / upgraded workers) never permanently holds an add the whole fleet refused. Covers the non-upsert Add verbs with unambiguous inverses (listeners →RemoveListener; HTTP/HTTPS frontends → the same payload under the Remove variant); upsert verbs (AddCluster/AddBackend) and certificates are deliberately uncovered (they would need prior-value capture, kept best-effort as today). A mixed result is left as-is to avoid diverging the master from workers that accepted.Security / protocol impact
Confined to the control-plane command-apply path (
bin/src/command/,command/src/state.rs) and listener construction (lib/src/{http,https,tcp,udp}.rs). It makes the main process's authoritativeConfigStateconsistent with what workers actually accepted. Conservative, additive validation; no behavior change on the accepted path, no traffic-path change.Tests
bin/src/command/requests.rs): invalid listener rejected before commit, corrected reload succeeds, andcompute_rollbackinverse correctness. Proven red (neutering the guard fails the assertions), then green.#[ignore]d e2e smoke test driving a real master over its command socket: confirms a correctedlistener https addsucceeds after an invalid one at the same address.Commands run
cargo build --all-features --locked— okcargo +nightly fmt --all -- --check— okcargo clippy --all-targets --locked -- -D warnings— okcargo test -p sozu -p sozu-lib -p sozu-command-lib --locked— ok (771 lib + bin + command)cargo test -p sozu --test listener_validate_before_commit_e2e -- --ignored— okDocs
CHANGELOG.mdupdated (Fixed, Invalid HTTPS listener config is committed to master state before the worker rejects it, blocking a corrected reload #1301).Closes #1301